我有一个肥皂服务器,我一直作为独立应用程序运行,即只需执行python mysoapserver.py
但是,我希望使用 wsgi 通过 apache2 访问它。
以下是当前代码的一些代码摘录:
进口:
from pysimplesoap.server import SoapDispatcher, SOAPHandler, WSGISOAPHandler
代码摘录
dispatcher = SoapDispatcher(
'TransServer',
location = "http://127.0.0.1:8050/",
action = 'http://127.0.0.1:8050/', # SOAPAction
namespace = "http://example.com/sample.wsdl", prefix="ns0",
trace = True,
ns = True)
#Function
def settransactiondetails(sessionId,msisdn,amount,language):
#Some Code here
#And more code here
return {'sessionId':sid,'responseCode':0}
# register the user function
dispatcher.register_function('InitiateTransfer', settransactiondetails,
returns={'sessionId': str,'responseCode':int},
args={'sessionId': str,'msisdn': str,'amount': str,'language': str})
logging.info("Starting server...")
httpd = HTTPServer(("", 8050),SOAPHandler)
httpd.dispatcher = dispatcher
httpd.serve_forever()
我需要如何更改上面的代码才能通过 wsgi 在 apache2 上访问它。您还可以包括我需要对/etc/apache2/sites-available/default
文件进行的更改。