当我运行以下代码时,我收到响应 500 内部服务器错误,我认为代码是完美的,所以有人可以帮我解决这个问题吗?
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<CountryListRQ echoToken="DummyEchoToken" xmlns="http://www.hotelbeds.com/schemas/2005/06/messages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.hotelbeds.com/schemas/2005/06/messages CountryListRQ.xsd">';
$xml .= '<Language>ENG</Language>';
$xml .= '<Credentials>';
$xml .= '<User>username</User>';
$xml .= '<Password>password</Password>';
$xml .= '</Credentials>';
$xml .= '</CountryListRQ>';
$url = 'http://212.170.239.71/appservices/ws/FrontendService?wsdl';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml; charset=utf-8; action="getCountryList"'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('xml' => $xml));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = @curl_exec($ch);
echo "<pre>";
print_r($result);
exit;
if($result === false) {
echo "Error performing request";
} else {
$xml_doc = simplexml_load_string($result);
echo 'status is ', $xml_doc->status, '<br/>';
if ($xml_doc->status == 'SUCCESS') {
print_r($result);
} else {
echo 'Error is ', $xml_doc->errormessage, '<br/>';
}
}?>
我得到了这样的回应,
HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
Date: Sat, 02 Feb 2013 06:02:12 GMT
Server: Resin/2.1.17
Content-Type: text/xml; charset=utf-8
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
soapenv:Server.userExceptionorg.xml.sax.SAXParseException: Content is not allowed in prolog.we3mpf01
谁能帮我?我如何使用这个hotelbed api获取国家列表?