2

我编写了一个 python 脚本来拥有一个带有烧瓶的肥皂服务器,这与文档中所说的完全一样:

from time import ctime
from flask import Flask
from flaskext.enterprise import Enterprise


if __name__ == '__main__':
    app = Flask(__name__)
    enterprise = Enterprise(app)

    class DemoService(enterprise.SOAPService):

        @enterprise.soap(_returns=enterprise._sp.String)
        def get_time(self):
            return ctime()

但是当我运行程序时,它说:

Traceback (most recent call last):
  File "D:/Workspace/src/flask_soap_server.py", line 3, in <module>
    from flaskext.enterprise import Enterprise
  File "C:\Python27\lib\site-packages\flaskext\enterprise.py", line 20, in <module>
    from soaplib.core import Application
ImportError: No module named core

我还写了一个客户端来调用这个服务器的 WSDL 地址:

from flaskext.enterprise import Enterprise
from flask import Flask


if __name__ == '__main__':

    app = Flask(__name__)
    enterprise = Enterprise(app)
    client = enterprise.connect_to_soap_service('http://192.168.20.232:8000/_enterprise/soap?wsdl')
    @app.route('/time')
    def index():
        time = client.service.get_time()
4

1 回答 1

0

肥皂库(https://github.com/soaplib/soaplib):

该项目已停止。请前往 github.com/arskom/spyne 获取下一个版本。

Flask Enterprise ( https://pypi.python.org/pypi/Flask-Enterprise ):2011 年的最新版本

也许是时候转移到更好的支持项目了:)

有一个 Spyne + Flask 示例:https ://github.com/arskom/spyne/tree/master/examples/flask

于 2015-05-18T09:24:52.560 回答