How to call soap api in php using curl method

40

<pre>
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => 
  "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\">
  <Body>
      <ListOfContinentsByCode xmlns=\"http://www.oorsprong.org/websamples.countryinfo\"/>
  </Body>
</Envelope>",
  CURLOPT_HTTPHEADER => array("content-type: text/xml"),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>
</pre>
//call soap API in php

Comments

Submit
0 Comments