Sathiska
Sathiska

Reputation: 525

Customize PHP SOAP Body Parameters according to WSDL File format

I am trying to send SOAP request to remote Server and following request message is required to send.

<SOAP-ENV:Body>
<ns1:F1>
<id>2323</id>
</ns1:F1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

But My Request is like this

<SOAP-ENV:Body>
<ns1:F1/>
<param1>2323</param1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

I used general php soap_client function from WAMP server like this.

 $client = new SoapClient("name.wsdl",array(
    "trace"      => 1,
    "exceptions" => 0 );

  $result = $client->F1($value);

How can I convert 2nd out put into first one. I need to change parameter name is change to F1 from param1 and correctly closed Body tag.

Upvotes: 3

Views: 2771

Answers (3)

DEVEX
DEVEX

Reputation: 137

Try to use Parameters inside __soapCall function,

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

$arrayname = array(
  XXXXXXXXX
);

$response = $client->__soapCall("F1", array($arrayname ));

Upvotes: 1

Scott Chapman
Scott Chapman

Reputation: 920

First, check that your WSDL URL is correct, as SoapClient uses the WSDL from the service to know what to name your parameters.

You can also specify your parameter name literally:

$response = $client->__soapCall('ns1:F1', array(new SoapParam('2323','id')));

Upvotes: 2

Sarcastron
Sarcastron

Reputation: 1527

How are you constructing value? You may need to create this variable as a multidimensional array if the web service is looking for a complex type. You can look for clues in the WSDL file if there is one.

$value = array(
           'F1' = array(
                    'id' => 2323
                       )
               );

Upvotes: 3

Related Questions