Question

I have following soap response. How can i call soap using php.Any Idea. Thanks in Advance.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">
         <wsse:UsernameToken>
            <wsse:Username>XXXXXXXXXXXX</wsse:Username>
            <wsse:Password>XXXXXXXXXXXXXXXXX</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soap:Header>
   <soapenv:Body>
      <cus1:GetCustomerDetailsRequest xmlns:cus1="XXXXXXXXXXXXXXXXXXXXXXX" xmlns:com="XXXXXXXXXXXXXXXXXXXXXXXX" xmlns:cus="XXXXXXXXXXXXXXXXX">
         <cus:GetCustomerDetails>
            <AccountMSISDN>1234567890</AccountMSISDN>
         </cus:GetCustomerDetails>
      </cus1:GetCustomerDetailsRequest>
   </soapenv:Body>
</soapenv:Envelope>
Was it helpful?

Solution

You should be able to have a play around with the fields, parameters and methods you need by using a free online soap tool like this:

http://www.soapclient.com/soaptest.html

Also, you should have a look at this answer: SOAP request in PHP with CURL

OTHER TIPS

$soapUrl = "http://www.example.com/masterdata/masterdata.asmx?wsdl";

$soapUser = "username";  //  username

$soapPassword = "password"; // password

// xml post structure

$xml_post_string = 'soap string';   // data from the form, e.g. some ID number

$headers = array(
          "Content-type: text/xml;charset=\"utf-8\"",
          "Accept: text/xml",
          "Cache-Control: no-cache",
          "Pragma: no-cache",
          "SOAPAction: http://tempuri.org/GetMasterData", 
          "Content-length: ".strlen($xml_post_string),
      ); //SOAPAction: your op URL

$url = $soapUrl;

// PHP cURL  for https connection with auth
$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_TIMEOUT, 10);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

// converting
$response = curl_exec($ch); 

curl_close($ch);

    // a new dom object 
 $dom = new domDocument('1.0', 'utf-8'); 

 // load the html into the object 
 $dom->loadXml($response);         

 $array = json_decode($dom->textContent,TRUE);

  print_r($array);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top