我编写了一个 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()