2011-07-06 127 views
0
//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; 
?> 

它表示SOAP请求不工作

后来内部服务器错误上我已经上面的XML使用xml2array类改变为阵列和我不停的结果在一个可变像

$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

在什么地方错误发生? '__call'已被弃用,你不应该使用'__soapCall'?你对“OTA_HotelDestinationsRQ”的论点是否正确?从WSDL我会期望'argRequest'和'argApplicationName'(作为'OTA_HotelDestinationsRQRequest'的一部分)? – Jorik

+0

显示无效的XML错误的肥皂响应。如果我们将上面的xml请求更改为数组,可能我会工作 – Hearaman

回答

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; 
?>