13

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
  • please provide the relevant parts of your wsdl-file if possible. the parameter-names should be stated there. Commented Aug 10, 2012 at 10:28

4 Answers 4

14

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"));
Sign up to request clarification or add additional context in comments.

1 Comment

After a failed try with new \SoapParam('user', 'param1') (not needing 2 params ATM), this worked.
4
$info = $client->__call("myAction", ['body' => ['param1' => '123', 'param2' => '456']]);

Comments

0

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.

Comments

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

Comments

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.