其他分享
首页 > 其他分享> > 带有mod_wsgi的soaplib,不带Django,Cherypy或其他框架

带有mod_wsgi的soaplib,不带Django,Cherypy或其他框架

作者:互联网

我在网上检查了soaplib的python并得到了示例

import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array


class HelloWorldService(DefinitionBase):
    @soap(String,Integer,_returns=Array(String))
    def say_hello(self,name,times):
        results = []
        for i in range(0,times):
            results.append('Hello, %s'%name)
        return results

if __name__=='__main__':
    try:
        from wsgiref.simple_server import make_server
        soap_application = soaplib.core.Application([HelloWorldService], 'tns')
        wsgi_application = wsgi.Application(soap_application)
        server = make_server('localhost', 7789, wsgi_application)
        server.serve_forever()
    except ImportError:
        print "Error: example server code requires Python >= 2.5"

这个例子很好用.但是我想用mod_wsgi在Apache中运行它.我检查了网,所有都带有django,cherrypy或pylone.是否可以在没有任何python网络框架的情况下运行此示例?在Apache的mod_wsgi下运行此示例需要遵循哪些步骤.我想在Unix中运行它.

解决方法:

类似于wiki中的所有其他“ Integration With”文档,但application = wsgi.Application(soap_application)除外.

标签:mod-wsgi,python,soaplib
来源: https://codeday.me/bug/20191208/2090045.html