Hi
I'm trying to send a request to a my webservice using curl
$content = '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://www.travelledia.it/XHI" xmlns:ns1="http://localhost/test/soap2/" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
<env:Header/>
<env:Body>
<ns1:OTA_HotelAvailRQ>
<AvailRequestSegments>
<AvailRequestSegment AvailReqType = "Room" ResponseType = "RateInfoDetails">
<HotelSearchCriteria>
<Criterion>
<HotelRef HotelCode="5095">xxx</HotelRef>
</Criterion>
</HotelSearchCriteria>
</AvailRequestSegment>
</AvailRequestSegments>
</ns1:OTA_HotelAvailRQ>
</env:Body>
</env:Envelope>';
// Assign headers
$headers = array("Content-type: text/xml;charset=\"utf-8\"",
"Accept: application/soap+xml, text/*",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-length: ".strlen($content),
);
// URL
$wsdl = "http://localhost/test/soap2/server/test2.php";
//CURL here
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $wsdl); // pass wsdl url here
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, '1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content); // pass content variable here
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // pass headers variable here
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Execute curl here
$resp = curl_exec($ch);
$res = htmlspecialchars($resp, ENT_QUOTES);
$res=str_replace('></','> <',$res);
$res=str_replace('><','><BR><',$res);
// print output here
print_r('<pre>');
print_r($res);
print_r('</pre>');
?>
With simple server page I return to the client the response:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
<env:Body xmlns:rpc="http://www.w3.org/2003/05/soap-rpc">
<ns1:OTA_HotelAvailRQResponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<rpc:result>return</rpc:result>
<return xsi:type="enc:Struct">
<AvailRequestSegment xsi:type="enc:Struct">
<HotelSearchCriteria xsi:type="enc:Struct">
<Criterion xsi:type="enc:Struct">
<HotelRef xsi:type="xsd:string">xxx</HotelRef> <Criterion> <HotelSearchCriteria> <AvailRequestSegment> <return> <ns1:OTA_HotelAvailRQResponse> <env:Body> <env:Envelope>
So you can see that no attributes is returned and the HotelCode attribute si missing !!!
Why this happens ?
Thanks in advance.
Regards.