2

Python Web Service Code:

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 Code:

<?php

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


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

    echo("<pre>");
    var_dump($client->__getFunctions());
    echo("</pre>");
    $params = array('World');


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

    } catch (SoapFault $exception) {
        echo $exception;
    }
?>

When I run my php code, it reports information below

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}

How to solve this problem? Thanks.

1
  • To look at WSDL (hello.wsdl) in this case is useful. Post it. Commented Feb 8, 2012 at 9:05

1 Answer 1

1

Not sure what SoapClient is exactly, but it just looks like it needs another argument. What does the documentation say?

Sign up to request clarification or add additional context in comments.

2 Comments

the documentation is referred to this link php.net/manual/en/class.soapclient.php I can not find any useful information in this documentation.
Could you try a var_dump() instead of echo for $exception and give us the response ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.