PHP call function SOAP client with parameters

I created the SOAP client like this:

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

And then when I want to call the API function

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

I get the following error:

When trying to deserialize the message, the formatter threw an exception:

Error deserializing the body of the request message for the Authentication operation. The final body element from the namespace ' http://schemas.xmlsoap.org/soap/envelope/ ' is expected. The element 'param1' from the namespace is found.

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

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

My question is: how to pass parameters to PHP for a SOAP client? Should they be in an array?

+7
source share
4 answers

you must pass an array for the parameters and specify the parameter names (you can find them in the wsdl file). in your case, the result should look like this (assuming the parameter names should be param1 and param2 based on the error message):

 $client->Authenticate(array('param1'=>"user", 'param2'=>"password")); 
+9
source
 $info = $client->__call("myAction", ['body' => ['param1' => '123', 'param2' => '456']]); 
+2
source

it all depends on how the soap server is determined, the parameters can be strings and arrays as you wish. Your problem is paralogically not legal earlier, check the wsdl file or the soap server.

0
source
  $client = new SoapClient("your wsdl file"); $stock = "NCR"; $parameters= array("request"=>$stock); $values = $client->someMethod($parameters); 
0
source

All Articles