Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CODE - UC SEG STATUS NOT ALLOWED-0003 when requesting EnhancedAirBookRQ

Tags:

php

curl

xml

sabre

I am currently using CURL in PHP to request XML. When using same flow in POSTMAN service I can get the success result but, when using CURL in PHP I get CODE - UC SEG STATUS NOT ALLOWED-0003 status. Below are my CURL request header and code. Is my header option in CURL request making the problem?

 function get_xml_response($xmldata) {
error_reporting(E_ALL);
$wsdl = 'https://sws3-crt.cert.sabre.com';

$header = array(
    "Content-type: text/xml;charset=\"utf-8\"",
    "Accept: text/xml",
    "Cache-Control: no-cache",
    "Pragma: no-cache",
    "SOAPAction: \"\"",
    "Content-length: " . strlen($xmldata),
);

$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "$wsdl");
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_setopt($soap_do, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 60); 
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xmldata);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);

  if (curl_exec($soap_do) === false) {
    $err = 'Curl error: ' . curl_error($soap_do);
    curl_close($soap_do);
    print $err;
    return false;
  } else {
    $response = curl_exec($soap_do);
    $httpcode = curl_getinfo($soap_do, CURLINFO_HTTP_CODE);
    return $response;
  }
}

EnhancedBookRQ.xml

    <?xml version="1.0" encoding="utf-8"?>
<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">
      <eb:From>
        <eb:PartyId eb:type="urn:x12.org.IO5:01">[email protected]</eb:PartyId>
      </eb:From>
      <eb:To>
        <eb:PartyId eb:type="urn:x12.org.IO5:01">webservices.sabre.com</eb:PartyId>
      </eb:To>
      <eb:ConversationId>[email protected]</eb:ConversationId>
      <eb:Service eb:type="SabreXML">Enhanced Air Book Request</eb:Service>
      <eb:Action>EnhancedAirBookRQ</eb:Action>
      <eb:CPAID>T198</eb:CPAID>
      <eb:MessageData>
        <eb:MessageId>mid:[email protected]</eb:MessageId>
        <eb:Timestamp>2016-10-17T05-27-10Z</eb:Timestamp>
        <eb:TimeToLive>2016-10-17T05-27-10Z</eb:TimeToLive>
      </eb:MessageData>
    </eb:MessageHeader>
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
      <wsse:BinarySecurityToken>Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/ACPCRTD!ICESMSLB\/CRT.LB!-3322625022286234335!532307!0</wsse:BinarySecurityToken>
    </wsse:Security>
  </soap-env:Header>
  <soap-env:Body>
    <EnhancedAirBookRQ xmlns="http://services.sabre.com/sp/eab/v3_6" version="3.6.0" HaltOnError="true">
      <OTA_AirBookRQ>
        <HaltOnStatus Code="UC"/>
        <HaltOnStatus Code="LL"/>
        <HaltOnStatus Code="UL"/>
        <HaltOnStatus Code="UN"/>
        <HaltOnStatus Code="NO"/>
        <HaltOnStatus Code="HL"/>
        <OriginDestinationInformation>
          <FlightSegment NumberInParty="1" Status="NN" FlightNumber="281" ResBookDesigCode="W" DepartureDateTime="2017-04-13T13:10:00" ArrivalDateTime="2017-04-13T14:40:00">
            <DestinationLocation LocationCode="DEL"/>
            <Equipment AirEquipType="73H"/>
            <MarketingAirline FlightNumber="281" Code="9W"/>
            <OriginLocation LocationCode="KTM"/>
          </FlightSegment>
        </OriginDestinationInformation>
      </OTA_AirBookRQ>
      <OTA_AirPriceRQ>
        <PriceRequestInformation Retain="true">
          <OptionalQualifiers>
            <FlightQualifiers>
              <VendorPrefs>
                <Airline Code="9W"/>
              </VendorPrefs>
            </FlightQualifiers>
            <PricingQualifiers CurrencyCode="NPR">
              <PassengerType Code="ADT" Force="true" Quantity="1"/>
              <Taxes>
                <TaxExempt Code="NQ"/>
              </Taxes>
            </PricingQualifiers>
          </OptionalQualifiers>
        </PriceRequestInformation>
      </OTA_AirPriceRQ>
      <PostProcessing IgnoreAfter="false">
        <RedisplayReservation/>
      </PostProcessing>
      <PreProcessing IgnoreBefore="false">            </PreProcessing>
    </EnhancedAirBookRQ>
  </soap-env:Body>
</soap-env:Envelope>

EnhancedBookRS.xml

    <?xml version="1.0" encoding="UTF-8"?>
<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" eb:version="1.0" soap-env:mustUnderstand="1">
      <eb:From>
        <eb:PartyId eb:type="urn:x12.org.IO5:01">webservices.sabre.com</eb:PartyId>
      </eb:From>
      <eb:To>
        <eb:PartyId eb:type="urn:x12.org.IO5:01">[email protected]</eb:PartyId>
      </eb:To>
      <eb:CPAId>T198</eb:CPAId>
      <eb:ConversationId>[email protected]</eb:ConversationId>
      <eb:Service eb:type="SabreXML">Enhanced Air Book Request</eb:Service>
      <eb:Action>EnhancedAirBookRS</eb:Action>
      <eb:MessageData>
        <eb:MessageId>bk97jgyj2</eb:MessageId>
        <eb:Timestamp>2017-01-03T06:01:43</eb:Timestamp>
        <eb:RefToMessageId>mid:[email protected]</eb:RefToMessageId>
      </eb:MessageData>
    </eb:MessageHeader>
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
      <wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/ACPCRTD!ICESMSLB\/CRT.LB!-3322625022286234335!532307!0</wsse:BinarySecurityToken>
    </wsse:Security>
  </soap-env:Header>
  <soap-env:Body>
    <EnhancedAirBookRS xmlns="http://services.sabre.com/sp/eab/v3_6">
      <ns2:ApplicationResults xmlns:ns2="http://services.sabre.com/STL_Payload/v02_01" status="NotProcessed">
        <ns2:Error type="BusinessLogic" timeStamp="2017-01-03T00:01:43.090-06:00">
          <ns2:SystemSpecificResults>
            <ns2:Message code="ERR.SWS.HOST.ERROR_IN_RESPONSE">CODE - UC SEG STATUS NOT ALLOWED-0003</ns2:Message>
          </ns2:SystemSpecificResults>
        </ns2:Error>
      </ns2:ApplicationResults>
      <OTA_AirBookRS>
        <OriginDestinationOption>
          <FlightSegment ArrivalDateTime="04-13T14:40" DepartureDateTime="04-13T13:10" FlightNumber="0281" NumberInParty="001" ResBookDesigCode="W" Status="NN" eTicket="true">
            <DestinationLocation LocationCode="DEL"/>
            <MarketingAirline Code="9W" FlightNumber="0281"/>
            <OriginLocation LocationCode="KTM"/>
          </FlightSegment>
        </OriginDestinationOption>
      </OTA_AirBookRS>
      <TravelItineraryReadRS>
        <TravelItinerary>
          <CustomerInfo/>
          <ItineraryInfo>
            <ItineraryPricing>
              <PriceQuote RPH="1">
                <MiscInformation>
                  <SignatureLine ExpirationDateTime="00:00" Source="SYS" Status="ACTIVE">
                    <Text>T198 T198*AGT 1131/03JAN17</Text>
                  </SignatureLine>
                  <TicketingFees Disclaimer="ONE OR MORE FORM OF PAYMENT FEES MAY APPLY"/>
                  <TicketingFees Disclaimer="ACTUAL TOTAL WILL BE BASED ON FORM OF PAYMENT USED"/>
                  <TicketingFees Disclaimer="FEE CODE     DESCRIPTION                         FEE">
                    <FeeInformation Amount="399" CurrenyCode="" Description="" FunctionCode="FCA" ServiceType="OB">- ANY CC</FeeInformation>
                  </TicketingFees>
                </MiscInformation>
                <PricedItinerary DisplayOnly="false" InputMessage="WPA9WMNPRP1ADTXOTE-NQRQ" RPH="1" StatusCode="A" TaxExempt="false" ValidatingCarrier="9W">
                  <AirItineraryPricingInfo>
                    <ItinTotalFare>
                      <BaseFare Amount="3425" CurrencyCode="NPR"/>
                      <Taxes>
                        <Tax Amount="6377" TaxCode="XT"/>
                        <TaxBreakdownCode TaxPaid="false">0NQ</TaxBreakdownCode>
                        <TaxBreakdownCode TaxPaid="false">791NP</TaxBreakdownCode>
                        <TaxBreakdownCode TaxPaid="false">1000B6</TaxBreakdownCode>
                        <TaxBreakdownCode TaxPaid="false">1159IN</TaxBreakdownCode>
                        <TaxBreakdownCode TaxPaid="false">3427YQ</TaxBreakdownCode>
                      </Taxes>
                      <TotalFare Amount="9802" CurrencyCode="NPR"/>
                      <Totals>
                        <BaseFare Amount="3425"/>
                        <Taxes>
                          <Tax Amount="6377"/>
                        </Taxes>
                        <TotalFare Amount="9802"/>
                      </Totals>
                    </ItinTotalFare>
                    <PassengerTypeQuantity Code="ADT" Quantity="01"/>
                    <PTC_FareBreakdown>
                      <Endorsements>
                        <Endorsement type="SYSTEM_ENDORSEMENT">
                          <Text>NON ENDO</Text>
                        </Endorsement>
                        <Endorsement type="PRICING_PARAMETER">
                          <Text>WPA9W$MNPR$P1ADT$XO$TE-NQ$RQ</Text>
                        </Endorsement>
                        <Endorsement type="WARNING">
                          <Text>VALIDATING CARRIER SPECIFIED - 9W</Text>
                        </Endorsement>
                      </Endorsements>
                      <FareBasis Code="W2STOWNP"/>
                      <FareCalculation>
                        <Text>KTM 9W DEL Q15.00 16.61NUC31.61END ROE108.347088</Text>
                      </FareCalculation>
                      <FareSource>ATPC</FareSource>
                      <FlightSegment ConnectionInd="O" DepartureDateTime="04-13T13:10" FlightNumber="281" ResBookDesigCode="W" SegmentNumber="1" Status="OK">
                        <BaggageAllowance Number="20K"/>
                        <FareBasis Code="W2STOWNP"/>
                        <MarketingAirline Code="9W" FlightNumber="281"/>
                        <OriginLocation LocationCode="KTM"/>
                        <ValidityDates>
                          <NotValidAfter>2017-04-13</NotValidAfter>
                          <NotValidBefore>2017-04-13</NotValidBefore>
                        </ValidityDates>
                      </FlightSegment>
                      <FlightSegment>
                        <OriginLocation LocationCode="DEL"/>
                      </FlightSegment>
                      <ResTicketingRestrictions>LAST DAY TO PURCHASE 10JAN/2359</ResTicketingRestrictions>
                      <ResTicketingRestrictions>GUARANTEED FARE APPL IF PURCHASED BEFORE 10JAN</ResTicketingRestrictions>
                    </PTC_FareBreakdown>
                  </AirItineraryPricingInfo>
                </PricedItinerary>
                <ResponseHeader>
                  <Text>FARE - PRICE RETAINED</Text>
                  <Text>FARE USED TO CALCULATE DISCOUNT</Text>
                  <Text>FARE NOT GUARANTEED UNTIL TICKETED</Text>
                </ResponseHeader>
                <PriceQuotePlus DiscountAmount="0" DisplayOnly="false" DomesticIntlInd="I" IT_BT_Fare="BT" ItineraryChanged="false" ManualFare="false" NUCSuppresion="false" NegotiatedFare="false" PricingStatus="M" SubjToGovtApproval="false" SystemIndicator="S" VerifyFareCalc="false">
                  <TicketingInstructionsInfo/>
                </PriceQuotePlus>
              </PriceQuote>
              <PriceQuoteTotals>
                <BaseFare Amount="3425.00"/>
                <Taxes>
                  <Tax Amount="6377.00"/>
                </Taxes>
                <TotalFare Amount="9802.00"/>
              </PriceQuoteTotals>
            </ItineraryPricing>
            <ReservationItems>
              <Item RPH="1">
                <FlightSegment AirMilesFlown="0507" ArrivalDateTime="04-13T14:40" DayOfWeekInd="4" DepartureDateTime="2017-04-13T13:10" ElapsedTime="01.45" FlightNumber="0281" IsPast="false" NumberInParty="01" ResBookDesigCode="W" SegmentNumber="0001" SmokingAllowed="false" SpecialMeal="false" Status="SS" StopQuantity="00" eTicket="true">
                  <DestinationLocation LocationCode="DEL" Terminal="TERMINAL 3" TerminalCode="3"/>
                  <Equipment AirEquipType="73H"/>
                  <MarketingAirline Code="9W" FlightNumber="0281"/>
                  <Meal Code="L"/>
                  <OriginLocation LocationCode="KTM"/>
                  <SupplierRef ID="DC9W"/>
                  <UpdatedArrivalTime>04-13T14:40</UpdatedArrivalTime>
                  <UpdatedDepartureTime>04-13T13:10</UpdatedDepartureTime>
                </FlightSegment>
              </Item>
              <Item RPH="2">
                <FlightSegment AirMilesFlown="0507" ArrivalDateTime="04-13T14:40" DayOfWeekInd="4" DepartureDateTime="2017-04-13T13:10" ElapsedTime="01.45" FlightNumber="0281" IsPast="false" NumberInParty="01" ResBookDesigCode="W" SegmentNumber="0002" SmokingAllowed="false" SpecialMeal="false" Status="UC" StopQuantity="00" eTicket="false">
                  <DestinationLocation LocationCode="DEL" Terminal="TERMINAL 3" TerminalCode="3"/>
                  <Equipment AirEquipType="73H"/>
                  <MarketingAirline Code="9W" FlightNumber="0281"/>
                  <Meal Code="L"/>
                  <OriginLocation LocationCode="KTM"/>
                  <SupplierRef ID="DC9W"/>
                  <UpdatedArrivalTime>04-13T14:40</UpdatedArrivalTime>
                  <UpdatedDepartureTime>04-13T13:10</UpdatedDepartureTime>
                </FlightSegment>
              </Item>
            </ReservationItems>
          </ItineraryInfo>
          <ItineraryRef AirExtras="false" InhibitCode="U" PartitionID="AA" PrimeHostID="1B">
            <Header>CURRENTLY DISPLAYING A PNR OWNED BY THE SABRE PRIME HOST</Header>
            <Header>RULES AND FUNCTIONALITY FOR THAT PRIME HOST WILL APPLY</Header>
            <Header>PRICE QUOTE RECORD - MODIFIED</Header>
            <Source PseudoCityCode="T198"/>
          </ItineraryRef>
          <SpecialServiceInfo RPH="001" Type="GFX">
            <Service SSR_Code="OSI">
              <Airline Code="1B"/>
              <Text>PLEASE TICKET FARE AS PER TKT/TL IN PQ</Text>
            </Service>
          </SpecialServiceInfo>
        </TravelItinerary>
      </TravelItineraryReadRS>
    </EnhancedAirBookRS>
  </soap-env:Body>
</soap-env:Envelope>
like image 617
user254153 Avatar asked Jan 03 '17 06:01

user254153


1 Answers

I have to check your code, One thing is that if you getting your result from postman .. Then there is a good option for getting curl code from the postman. By click on code > change HTTP option to PHP curl >copy to clipboard . If you try with this way of write code, you have to change little changes.

And one more thing, A very good answer have given here UC status . UC status related to UN-CONFIRMED status. Please have a look here. Thanks

This is an example , for how to pass your post field data in xml form :

 $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_PORT => "",
      CURLOPT_URL => "url here",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n  <soap:Body> soap body part </soap:Body>\n</soap:Envelope>",
      CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache",
        "content-type: text/xml"
      ),
    ));
    $response = curl_exec($curl);
    $err = curl_error($curl);
    curl_close($curl);
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
like image 127
Kumar Rakesh Avatar answered Oct 13 '22 01:10

Kumar Rakesh