取消完整的PNR

时间:2016-02-15 11:47:17

标签: sabre

我正在编写一个自动取消某个队列上的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);
          }
});

它编译&amp;构建,但我还没有开始测试它。 : - )

在文档中我发现了以下请求:

<OTA_CancelRQ Version="2.0.0">
  <Segment Type="entire"/>
</OTA_CancelRQ>

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

5 个答案:

答案 0 :(得分:5)

取消PNR的步骤如下:

第1步:SessionCreateRQ

第2步:TravelItineraryReadRQ

第3步:OTA_CancelRQ

第4步:EndTransactionRQ

第5步:SessionCloseRQ

对于SOAP服务,您对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>

我希望这会让你的知识更清晰。

答案 1 :(得分:2)

您可以指定“整个”类型,如下所示取消PNR的整个行程。

<OTA_CancelRQ Version="2.0.0">
  <Segment Type="entire"/>
</OTA_CancelRQ>

答案 2 :(得分:2)

这是我在c#中的代码的请求部分,希望这有助于为OTA_CancelRQ的代理类添加一个参考。

OTA_CancelRQ rq = new OTA_CancelRQ();
        List<OTA_CancelRQSegment> segmentCancelList = new List<OTA_CancelRQSegment>();
        OTA_CancelRQSegment segmentCancel = new OTA_CancelRQSegment();
        OTA_CancelRQSegmentType segmentType = new OTA_CancelRQSegmentType();
        segmentType = OTA_CancelRQSegmentType.entire;
        segmentCancel.Type = segmentType;
        segmentCancel.TypeSpecified = true;
        segmentCancelList.Add(segmentCancel);
        rq.Segment = segmentCancelList.ToArray();

感谢。

答案 3 :(得分:0)

cancelRQ.tPA_ExtensionsField = new CancelRequest.TPA_Extensions
            {
                segmentCancelField = new CancelRequest.TPA_Extensions.SegmentCancel
                {
                    typeField = "Entire"
                }
            };

答案 4 :(得分:0)

致电OTA_CancelLLSRQ,请在原始预订完成后执行一笔交易(在这种情况下,取消预订的行程)。