PHP SOAP客户端向 PYTHON SOAPLIB+WEB.PY 通信问题
PHP SOAP客户端 与 PYTHON的 SOAPLIB+WEB.PY 服务端 进行通信时i,,服务端函数只一个参数的时候可以返回结果,但两个参数时候就报错,折腾很久了 望指点
PHP客户端:
<?php @ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient('http://localhost:8090/spider.wsdl'); var_dump($client->__getFunctions()); $param = array(); $param['str'] = 'my str'; $param['path'] = 'my path'; try { print_r($client->hello($param));} catch (SoapFault $exception) { echo $exception;}?>
#coding=utf-8
import web
from soaplib.wsgi_soap import SimpleWSGISoapApp
from soaplib.service import soapmethod
from soaplib.serializers import primitive as soap_types
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
urls = ("/spider", "SpiderService",
"/spider.wsdl", "SpiderService",
)
render = web.template.Template("$def with (var)\n$:var")
class SoapService(SimpleWSGISoapApp):
"""Class for webservice """
@soapmethod(soap_types.String,_returns=soap_types.String)
def hello(self, str, path):
"""Method for webservice"""
return str+path
class SpiderService(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()