Cancel a complete PNR

喜欢而已 提交于 2021-02-19 06:03:33

问题


I'm writing a service which automtically cancels a PNR left on a certain queue. This sounds pretty straight forward with the OTA_CancelLLSRQ request, however it appears I have to loop through each segment individually, or is there a way I can cancell ALL segments at once?

In the application we defined a PNR class, this class contains all of the information we can obtain with the "" call.

To cancel the PNR I currently use the following code:

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);
          }
});

It compiles & builds, but I haven't gotten around testing it just yet. :-)

In the documentation I found the following request:

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

How do I encode this using the object model the webservice expects?


回答1:


Steps for cancelling PNR is as follows.

STEP1: SessionCreateRQ

STEP2: TravelItineraryReadRQ

STEP3: OTA_CancelRQ

STEP4: EndTransactionRQ

STEP5: SessionCloseRQ

In case of SOAP SERVICES your request XML for STEP3 (i.e OTA_CancelRQ)will be as follows.

<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>

I hope this will make your knowledge more clear.




回答2:


You can specify "entire" type like the below to cancel the entire Itinerary of a PNR.

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



回答3:


here is the request part of my code in c#, hope this help add a refrence to proxy class for 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();

Thanks.




回答4:


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



回答5:


call OTA_CancelLLSRQ Perform a transaction after the original booking was completed (cancel the itinerary that was booked, in this case).



来源:https://stackoverflow.com/questions/35408584/cancel-a-complete-pnr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!