首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

PHP SOAP客户端向 PYTHON SOAPLIB+WEB.PY 通信有关问题

2012-03-29 
PHP SOAP客户端向 PYTHON SOAPLIB+WEB.PY 通信问题PHPSOAP客户端 与 PYTHON的 SOAPLIB+WEB.PY服务端 进行

PHP SOAP客户端向 PYTHON SOAPLIB+WEB.PY 通信问题
PHP SOAP客户端 与 PYTHON的 SOAPLIB+WEB.PY 服务端 进行通信时i,,服务端函数只一个参数的时候可以返回结果,但两个参数时候就报错,折腾很久了 望指点


PHP客户端:

PHP code
<?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;}?>





PYTHON 服务端
Python code
#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()






返回的错误代码:

SoapFault exception: [{SpiderService.SpiderService}helloFault] hello() takes exactly 3 arguments (2 given) in D:\phpnow\htdocs\echo.php:10

[解决办法]
推荐用phprpc试试,比SOAP要简单的多。

热点排行