Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP SOAP client calling function with parameters

Tags:

php

soap

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?

like image 767
gorgi93 Avatar asked Aug 10 '12 10:08

gorgi93


People also ask

How can make SOAP call in PHP?

To make SOAP requests to the SOAP API endpoint, use the "Content-Type: application/soap+xml" request header, which tells the server that the request body contains a SOAP envelope. The server informs the client that it has returned a SOAP envelope with a "Content-Type: application/soap+xml" response header.

What is Soapclient?

SOAP is a communications XML-based protocol that lets applications exchange information through the internet. SOAP is platform independent and language independent. SOAP uses XML to specify a request and reply structure.

What is SOAP protocol in PHP?

SOAP stands for Simple Object Access Protocol. SOAP is an application communication protocol. SOAP is a format for sending and receiving messages. SOAP is platform independent.

What is SOAP in laravel?

Soap is a plug-and-play package for Laravel that makes SOAP (dare I say) enjoyable to work with in your applications. If you've worked with the Http client introduced in Laravel 7, you'll feel right at home.


1 Answers

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"));
like image 194
oezi Avatar answered Oct 22 '22 07:10

oezi