2016-12-04 56 views
0

我收到以下錯誤消息軍刀 - 酒店預訂API - 錯誤

<faultcode>soap-env:Client.InvalidSecurityToken</faultcode><faultstring>Invalid or Expired binary security token: null</faultstring><detail><StackTrace>com.sabre.universalservices.base.security.AuthenticationException: errors.session.USG_INVALID_SECURITY_TOKEN</StackTrace></detail></soap-env:Fault></soap-env:Body></soap-env:Envelope> 

以下是我的要求酒店供應API。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Header> 
     <eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" SOAP-ENV:mustUnderstand="0"> 
      <eb:From> 
       <eb:PartyId eb:type="urn:x12.org:IO5:01">client</eb:PartyId> 
      </eb:From> 
      <eb:To> 
       <eb:PartyId eb:type="urn:x12.org:IO5:01">ws</eb:PartyId> 
      </eb:To> 
      <eb:CPAId>'.$pcc.'</eb:CPAId> 
      <eb:ConversationId>YourConversationId</eb:ConversationId> 
      <eb:Service eb:type="sabreXML"></eb:Service> 
      <eb:Action>OTA_HotelAvailLLSRQ</eb:Action> 
     </eb:MessageHeader> 
     <Security xmlns:ns6="http://schemas.xmlsoap.org/ws/2002/12/secext" SOAP-ENV:mustUnderstand="0"> 
      <BinarySecurityToken>'.$sabreKey.'</BinarySecurityToken> 
     </Security> 
    </SOAP-ENV:Header> 
    <SOAP-ENV:Body> 
     <eb:OTA_HotelAvailRQ xmlns:eb="http://webservices.sabre.com/sabreXML/2003/07" TimeStamp="2011-01-26T12:30:00-06:00" Version="1.10.1"> 
      <eb:POS> 
       <eb:Source PseudoCityCode="'.$pcc.'" /></eb:POS> 
      <eb:AvailRequestSegments> 
       <eb:AvailRequestSegment> 
        <eb:StayDateRange Start="12-10" End="12-15" /> 
        <eb:RoomStayCandidates> 
         <eb:RoomStayCandidate> 
          <eb:GuestCounts> 
           <eb:GuestCount Count="1" /></eb:GuestCounts> 
         </eb:RoomStayCandidate> 
        </eb:RoomStayCandidates> 
        <eb:HotelSearchCriteria xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="eb:HotelSearchCriteria_type0"> 
         <eb:Criterion> 
          <eb:HotelRef HotelCityCode="DFW" /></eb:Criterion> 
        </eb:HotelSearchCriteria> 
       </eb:AvailRequestSegment> 
      </eb:AvailRequestSegments> 
     </eb:OTA_HotelAvailRQ> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

這是我發出請求到酒店預訂API之前做了什麼。我收到了我的wsse:來自SessionCreateRQ的BinarySecurityToken將包含該令牌的變量存儲到。

<BinarySecurityToken>'.$sabreKey.'</BinarySecurityToken>                    

爲什麼我得到這個錯誤消息我的憑據是正確的。順便說一句,我有生產證書。

謝謝,我很期待一些幫助

回答

0

如果你是積極的,安全令牌是正確的,你可能會在不正確的環境中工作。例如,如果您在PROD上創建會話但將後續請求發送給CERT,則會返回此錯誤。

確保兩個請求都發送到同一端點。如果問題仍然存在,請聯繫幫助臺。

+0

感謝您的回覆。布魯諾。這兩個請求都被髮送到同一端點。我找出問題所在,那不是它。我會在幾分鐘後發佈解決方案,因爲我確信我的解決方案將有助於很多未來面臨同樣問題的人。 –

0

問題已解決。以下是Sabre文檔所述的問題,以在請求中包含以下標記。

<eb:Security xmlns:ns6="http://schemas.xmlsoap.org/ws/2002/12/secext" SOAP-ENV:mustUnderstand="0"> 
     <eb:BinarySecurityToken>'.$sabreKey.'</eb:BinarySecurityToken> 
    </eb:Security> 

但是那樣會導致錯誤。

所以我然後嘗試刪除eb命名空間和我的標籤下面的地方。

<Security xmlns:ns6="http://schemas.xmlsoap.org/ws/2002/12/secext" SOAP-ENV:mustUnderstand="0"> 
     <BinarySecurityToken>'.$sabreKey.'</BinarySecurityToken> 
    </Security> 

如果你看看我的結果中的xml請求。你會明白這是行不通的。然後,我嘗試再次更改標籤並使其正常工作。

我正在使用的標籤不在我正在閱讀的文檔中。這就是讓我困惑的原因。通過使用以下標籤是我如何得到我的請求工作。

<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"> 
<wsse:BinarySecurityToken valueType="String"  EncodingType="wsse:Base64Binary">'.$sabreKey.'</wsse:BinarySecurityToken> 
</wsse:Security> 

我相信這會幫助很多人,因爲文檔在涉及到這個特定標籤時存在缺陷。