110,536
社区成员
发帖
与我相关
我的任务
分享
//添加web引用http://127.0.0.1:8080/hello.wsdl为WS
WS.HelloService ws = new PYBETEST.WS.HelloService();
WS.hello inp = new PYBETEST.WS.hello();
inp.message = "me";
WS.helloResponse re = ws.hello(inp);
//re为null
import web
from soaplib.wsgi_soap import SimpleWSGISoapApp
from soaplib.service import soapmethod
from soaplib.serializers import primitive as soap_types
urls = ("/hello", "HelloService",
"/hello.wsdl", "HelloService",
)
render = web.template.Template("$def with (var)\n$:var")
class SoapService(SimpleWSGISoapApp):
"""Class for webservice """
#__tns__ = 'http://test.com'
@soapmethod(soap_types.String,_returns=soap_types.String)
def hello(self,message):
""" Method for webservice"""
return "Hello world "+message
class HelloService(SoapService):
"""Class for web.py """
def start_response(self,status, headers):
web.ctx.status = status
for header, value in headers:
web.header(header, value)
def GET(self):
response = super(SimpleWSGISoapApp, self).__call__(web.ctx.environ, self.start_response)
return render("\n".join(response))
def POST(self):
response = super(SimpleWSGISoapApp, self).__call__(web.ctx.environ, self.start_response)
return render("\n".join(response))
app=web.application(urls, globals())
if __name__ == "__main__":
app.run()
from soaplib.client import make_service_client
from testServer import HelloService
client = make_service_client('http://localhost:8080/hello', HelloService())
a= client.hello('me')
print a
#Hello world me