** Как напечатать результат xml soap api как json или xml с php ** Я раньше не работал с SOAP API.Я хочу выполнить SOAP API с запросом данных XML.Я пытался, но не получил результат.
// The URL to POST to
$url = "https://api.tbotechnology.in/HotelAPI_V7/HotelService.svc";
// The value for the SOAPAction: header
$action = "http://TekTravel/HotelBookingApi/CountryList";
// Get the SOAP data into a string, I am using HEREDOC syntax
// but how you do this is irrelevant, the point is just get the
// body of the request into a string
$mySOAP = <<<EOD
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:hot="http://TekTravel/HotelBookingApi">
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<hot:Credentials UserName="***" Password="***"> </hot:Credentials>
<wsa:Action>http://TekTravel/HotelBookingApi/CountryList</wsa:Action>
<wsa:To>https://api.tbotechnology.in/HotelAPI_V7/HotelService.svc</wsa:To>
</soap:Header>
<soap:Body>
<hot:CountryListRequest/>
</soap:Body>
</soap:Envelope>
EOD;
$headers = array(
'Content-Type: application/soap+xml; charset=UTF-8',
'Content-Length: '.strlen($mySOAP),
'SOAPAction: ' .$action
);
// Build the cURL session
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $mySOAP);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// Send the request and check the response
if (($result = curl_exec($ch)) === FALSE) {
die('cURL error: '.curl_error($ch)."<br />\n");
} else {
echo "Success!<br />\n";
echo $result;
}
curl_close($ch);