gorgi93 gorgi93 -4 years ago 187
PHP Question

PHP SOAP client calling function with parameters

I created a SOAP client like so:

$client = new SoapClient("file.wsdl");


And then when I want to call an API function

$client->Authenticate("user", "password");


I get the following error:


The formatter threw an exception while trying to deserialize the message:

Error in deserializing body of request message for operation 'Authenticate'.
End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected.
Found element 'param1' from namespace ''.


But when I try to pass parameters in an array, it works, but I get the next error:

["errorMessage"]=>
string(35) "ORA-01008: not all variables bound


My question is: How can I pass parameters in PHP to the SOAP client? Do they have to be in an array?

Answer Source

you should pass an array for the parameters and give your parameters names (those can be found in the wsdl-file). in your case, the result should look like this (assuming the parameter-names should be param1 and param2 on the basis of the error-message):

$client->Authenticate(array('param1'=>"user", 'param2'=>"password"));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download