我正在编写一项服务,该服务会自动取消保留在特定队列上的PNR。对于OTA_CancelLLSRQ请求,这听起来很简单,但是看来我必须逐一遍历每个段,或者有没有一种方法可以一次取消所有段?

在应用程序中,我们定义了一个PNR类,该类包含我们可以通过“”调用获得的所有信息。

要取消PNR,我目前使用以下代码:

MessageHeader msgHeader = new MessageHeader
{
    ConversationId = "TestSession",
    CPAId = licenseId,
    Action = "OTA_CancelLLSRQ",
    Service = new Service { Value = "OTA_CancelLLSRQ" },
    MessageData = new MessageData
    {
        MessageId = "xxx",
        Timestamp = DateTime.UtcNow.ToString("s") + "Z"
    },
    From = new From()
    {
        PartyId = new PartyId[]
        {
            new PartyId { Value = "WebServiceClient"}
        }
    },
    To = new To()
    {
        PartyId = new[]
        {
            new PartyId { Value = "WebServiceSupplier"}
        }
    }
};

var segmentList = new List<OTA_CancelRQSegment>();
foreach (var segment in pnrObject.Segments)
{
    var requestSegment = new OTA_CancelRQSegment
    {
        Number = segment.SegmentNumber.ToString()
    };

    segmentList.Add(requestSegment);
}

var request = new OTA_CancelRQ()
{
    Version = "2.0.0",
    TimeStamp = DateTime.UtcNow,
    TimeStampSpecified = true,
    Segment = segmentList.ToArray()
};

OTA_CancelRS response = null;
Policy.Handle<SoapException>()
      .Or<WebException>()
      .WaitAndRetry(new[]
      {
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1),
          TimeSpan.FromSeconds(1)
      })
      .Execute(() =>
      {
          using (OTA_CancelService serviceObj = new OTA_CancelService())
          {
              serviceObj.MessageHeaderValue = msgHeader;
              serviceObj.Security = new Security1 { BinarySecurityToken = token };
              response = serviceObj.OTA_CancelRQ(request);
          }
});

它可以编译和构建,但是我还没有进行测试。 :-)

在文档中,我发现了以下请求:
<OTA_CancelRQ Version="2.0.0">
  <Segment Type="entire"/>
</OTA_CancelRQ>

如何使用Web服务期望的对象模型对此进行编码?

最佳答案

取消PNR的步骤如下。

步骤1:SessionCreateRQ

步骤2:TravelItineraryReadRQ

步骤3:OTA_CancelRQ

步骤4:EndTransactionRQ

步骤5:SessionCloseRQ

如果是SOAP SERVICES,您对STEP3的请求XML(即OTA_CancelRQ)将如下所示。

<OTA_CancelRQ EchoToken="String" TimeStamp="2001-12-17T09:30:47-05:00" Target="Production" Version="2003A.TsabreXML1.0.1" SequenceNmbr="1" PrimaryLangID="en-us" AltLangID="en-us" xmlns="http://webservices.sabre.com/sabreXML/2003/07" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <POS>
        <Source PseudoCityCode="PCC"/>
    </POS>
    <TPA_Extensions>
        <SegmentCancel Type="Entire">
        </SegmentCancel>
    </TPA_Extensions>
</OTA_CancelRQ>

希望这会使您的知识更加清楚。

10-04 22:09