PHP SOAP client calling function with parameters

为君一笑 提交于 2019-12-21 08:45:19

问题


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?


回答1:


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



回答2:


$info = $client->__call("myAction", ['body' => ['param1' => '123', 'param2' => '456']]);



回答3:


it all depends on how the soap server defines,parameters can be string and array as you like.your problem is paras not legal previously,check the wsdl file or the soap server.




回答4:


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


来源:https://stackoverflow.com/questions/11899706/php-soap-client-calling-function-with-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!