pythonweb php,使用PHP调用Python Web服务

Python Web服务代码:

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 """

@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()

PHP代码:

@ini_set("soap.wsdl_cache_enabled", "0");

$client = new SoapClient('http://localhost:8080/hello.wsdl');

echo("

");

var_dump($client->__getFunctions());

echo("

");

$params = array('World');

try {

print_r($client->__soapCall('hello', $params));

} catch (SoapFault $exception) {

echo $exception;

}

?>

当我运行我的PHP代码时,它会报告以下信息

SoapFault exception: [helloFault] hello() takes exactly 2 arguments (1

given) in C:\website\cosmetics\src\test02.php:15 Stack trace: #0

C:\website\cosmetics\src\test02.php(15):

SoapClient->__soapCall(‘hello’, Array) #1 {main}

如何解决这个问题呢?谢谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值