//PHP CODE
<?php
$xmlData='<OTA_HotelDestinationsRQ Version="1.0">
<POS>
<Source>
<UniqueId Id="user:password" />
</Source>
</POS>
<DestinationInformation LanguageCode="EN" />
</OTA_HotelDestinationsRQ>';
$wsdl="http://acceptance.travelstreet.com/hotelsv3/components/Hotels_DestinationsWS.cfc?wsdl";
$client=new SoapClient($wsdl,array('trace' => 1));
try
{
$res=$client->__call("OTA_HotelDestinationsRQ",array($xmlData));
}
catch (SoapFault $Exception)
{
echo 'SoapFault Exception';
}
echo $res;
?>
显示内部服务器错误
后来我使用xml2array类将xml更改为数组,并将结果保存在一个变量中,如
$iArray=xml2array($xmlData);
使用这个我编码如下:
<?php
$xmlData='<OTA_HotelDestinationsRQ Version="1.0">
<POS>
<Source>
<UniqueId Id="user:password" />
</Source>
</POS>
<DestinationInformation LanguageCode="EN" />
</OTA_HotelDestinationsRQ>';
$wsdl="http://acceptance.travelstreet.com/hotelsv3/components/Hotels_DestinationsWS.cfc?wsdl";
$client=new SoapClient($wsdl,array('trace' => 1));
try
{
$res=$client->__call("OTA_HotelDestinationsRQ",$iArray);
// (or) also check with bellow statement
$res=$client->OTA_HotelDestinationsRQ($iArray);
}
catch (SoapFault $Exception)
{
echo 'SoapFault Exception';
}
echo $res;
?>
显示无效的Xml错误
答案 0 :(得分:0)
您好我遇到了同样的错误,但随后@Pete here,帮助我使用此代码段,请尝试使用此代码段,也可能对您有用..
<?php
$xmlData='<OTA_HotelDestinationsRQ Version="1.0">
<POS>
<Source>
<UniqueId Id="user:password" />
</Source>
</POS>
<DestinationInformation LanguageCode="EN" />
</OTA_HotelDestinationsRQ>';
$client = new SOAPClient(
'http://acceptance.travelstreet.com/hotelsv3/components/Hotels_DestinationsWS.cfc?wsdl',
array(
'location' => 'http://acceptance.travelstreet.com/hotelsv3/components/Hotels_DestinationsWS.cfc',
'trace' => 1,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
)
);
$result = array();
$params = array("YourXMLParameterName" => $request);
try
{
$result = $client->__soapCall('getAllDepartments', array("parameters"=>$params));
}
catch (SoapFault $Exception)
{
echo "SOAP Fault: ".$e->getMessage()."<br />\n";
}
echo $res;
?>