2015-04-09 2 views
1

Я создал запрос на мыло для гостиниц, но все время получаю сообщение об ошибке при тестировании. Я новичок в кодировании & stackoverflow, поэтому, пожалуйста, выделите, пропустил ли я что-нибудь.Hotel Soap API Ошибка = Преждевременный конец файла

Ошибка, указанная здесь в файле: php code;

<soap-env:Envelope><soap-env:Header/><soap-env:Body><soap-env:Fault><faultcode>soap-env:Client.InvalidEbXmlMessage</faultcode><faultstring>Unable to create envelope from given source: Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.</faultstring><detail><StackTrace>javax.xml.soap.SOAPException: Unable to create envelope from given source: Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.</StackTrace></detail></soap-env:Fault></soap-env:Body></soap-env:Envelope> 

Кодекса Я использую:

<?php 
//sws-crt.cert.sabre.com // https://sws3-sts.cert.sabre.com 
//Data, connection, auth 
$soapUrl = "https://sws-crt.cert.sabre.com"; // asmx URL of WSDL 
//?op=OTA_HotelAvail 
// xml post structure 

$xml_post_string = '<SOAP-ENV:Envelope xmlns:SOAP- ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> 
        <SOAP-ENV:Header> 
        <wsse:Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:mustUnderstand="1"> 
        <wsse:UsernameToken xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
        <wsse:Username>xxx</wsse:Username> 
        <wsse:Password>xxx</wsse:Password> 
        </wsse:UsernameToken> 
        </wsse:Security> 
        </SOAP-ENV:Header> 
       <SOAP-ENV:Body> 
      <OTA_HotelAvailRQ Version="2.1.0" xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<AvailRequestSegment> 
<Customer> 
    <Corporate> 
    <ID>ABC123</ID> 
    </Corporate> 
</Customer> 
<GuestCounts Count="2"/> 
<HotelSearchCriteria> 
    <Criterion> 
    <HotelRef HotelCityCode="HNL"/> 
    </Criterion> 
</HotelSearchCriteria> 
<TimeSpan End="06-28" Start="06-20"/> 
</AvailRequestSegment> 
</OTA_HotelAvailRQ> 
      </SOAP-ENV:Body> 
      </SOAP-ENV:Envelope>'; // data from the form, e.g. some ID number 

$headers = array(
"Content-type: text/xml;charset=\"utf-8\"", 
"Accept: text/xml", 
"Authorization: Bearer Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/ACPCRTD!ICESMSLB\/CRT.LB!-3547302473499669854!495515!0!!E2E-1 X-Originating-Ip: xxxxxx ", 
"Cache-Control: no-cache", 
"Pragma: no-cache", 
"SOAPAction: OTA_HotelAvailLLSRQ", 
"Content-length: " . strlen($xml_post_string) 
); //SOAPAction: your op URL 

$url = $soapUrl; 

// PHP cURL for https connection with auth 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
//curl_setopt($ch, CURLOPT_USERPWD, "powderwhite:B=Antika789"); // username and password - declared at the top of the doc 
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

header('Content-type: text/xml'); 
// converting 
$response = curl_exec($ch); 
curl_close($ch); 
//echo "<pre>"; 
print_r($response); 
// converting 
/// $response1 = str_replace("<soap:Body>","",$response); 
// $response2 = str_replace("</soap:Body>","",$response1); 
// convertingc to XML 
// $parser = simplexml_load_string($response2); 
// user $parser to get your data out of XML response and to display it. 
//echo $parser; 
?>  

ответ

0

Если это Saber SOAP API, которые вы ищете, чтобы потреблять, вы должны передать как часть заголовка SOAP маркера сеанса, который был создан и возвращается из службы SessionCreateRQ. Сессия не передается в заголовке. Пример размещен ниже:

<?xml version="1.0" ?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <SOAP-ENV:Header> 
     <m:MessageHeader xmlns:m="http://www.ebxml.org/namespaces/messageHeader"> 
      <m:From> 
       <m:PartyId type="urn:x12.org:IO5:01">99999</m:PartyId> 
      </m:From> 
      <m:To> 
       <m:PartyId type="urn:x12.org:IO5:01">123123</m:PartyId> 
      </m:To> 
      <m:CPAId>ABC</m:CPAId> 
      <m:ConversationId>abc123</m:ConversationId> 
      <m:Service m:type="OTA"/> 
      <m:Action>OTA_HotelAvailLLSRQ</m:Action> 
      <m:MessageData> 
       <m:MessageId>mid:[email protected]</m:MessageId> 
       <m:Timestamp>2001-02-15T11:15:12Z</m:Timestamp> 
       <m:TimeToLive>2001-02-15T11:15:12Z</m:TimeToLive> 
      </m:MessageData> 
      <m:DuplicateElimination/> 
      <m:Description>Hotel Request</m:Description> 
     </m:MessageHeader> 
     <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"> 
      <wsse:BinarySecurityToken EncodingType="wsse:Base64Binary" valueType="String">Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/RESF!ICESMSLB\/RES.LB!-3552340994681278428!1838077!0!1!E2E-1</wsse:BinarySecurityToken> 
     </wsse:Security> 
    </SOAP-ENV:Header> 
    <SOAP-ENV:Body> 
     <OTA_HotelAvailRQ Version="2.1.0" xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
      <AvailRequestSegment> 
       <Customer> 
        <Corporate> 
         <ID>ABC123</ID> 
        </Corporate> 
       </Customer> 
       <GuestCounts Count="2"/> 
       <HotelSearchCriteria NumProperties="50"> 
        <Criterion> 
         <HotelRef HotelCityCode="DFW" HotelName="HYATT"/> 
        </Criterion> 
       </HotelSearchCriteria> 
       <TimeSpan End="06-28" Start="06-20"/> 
      </AvailRequestSegment> 
     </OTA_HotelAvailRQ> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

 Смежные вопросы

  • Нет связанных вопросов^_^