stupid soap question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

stupid soap question

Post by yacahuma »

If I need to call a web service method that has no parameters:

Code: Select all

$client = new SoapClient("http://localhost/mywsdl?WSDL");

print($client->__call(
        /* SOAP Method Name */
        "isServiceAvailable",
        /* Parameters */
        NULL
        ));
What do I pass instead of NULL???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why are you calling __call()? An empty array should suffice.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Fatal error

Post by yacahuma »

I changed the code to

Code: Select all

$client = new SoapClient("http://localhost/ada_testing/AdaAPI?WSDL")
$client->__soapCall("isAdaAvailable", array());
and I am getting
Fatal error: Uncaught SoapFault exception: [HTTP] Unable to parse URL in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test\test.php:16 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'REPLACE_WITH_AC...', '', 1, 0) #1 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test\test.php(16): SoapClient->__soapCall('isAdaAvailable', Array) #2 {main} thrown in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test\test.php on line 16

if I do

Code: Select all

var_dump($client->__getFunctions());
I get all the functions , so at least I need the service is responding. The service is supposed to return a boolean.

The actual service is in Java.



BTW, What soap library should I be using in production environment???
There seems to be nusoap,pear, the one in php5...
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

nuSoap craps out in php5. I just use the one that came with php5. The big problem with the php5 client is it can't decode multipart responses without extending the class and doing a significant amount of hacking.

As for your problem, if you are using a wsdl then you don't need to use __call, you can just do this.

Code: Select all

$client->isAdaAvailable()
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

FOUND PROBLEM IS WSDL

Post by yacahuma »

I found the problem. The wsdl contained a string REPLACE_WITH_ACCURATE_URL. Apparently the guy that did it forgot to put the url where the REPLACE_WITH_ACCURATE_URL was.

I changed the wsdl and it works now. I did use wsdl2php to do it.

Thank you. I did learn that I dont have to use the __call stuff
Post Reply