开发者

Soap request is not working

开发者 https://www.devze.com 2023-03-17 19:29 出处:网络
//PHP CODE <?php $xmlData=\'<OTA_HotelDestinationsRQ Version=\"1.0\"> <POS> <Source>
//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;
?>

It is showing Internal Server error

Later on i have changed above xml into array using xml2array class and i kept the result in one variable like

$iArray=xml2array($xmlData); Using this i have coded like:

<?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 st开发者_JS百科atement
     $res=$client->OTA_HotelDestinationsRQ($iArray);
}
catch (SoapFault $Exception)
{
     echo 'SoapFault Exception';
}
echo $res;
?>

It is showing Invalid Xml error


Hi I was getting same kind of error but then @Pete here , helped me with this code snippet , please try to use this code snippet may be it can work for you as well..

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

精彩评论

暂无评论...
验证码 换一张
取 消