我目前在PHP中使用CURL来请求XML。当在POSTMAN服务中使用相同的流程时,我可以获得成功结果但是,当在PHP中使用CURL时,我得到CODE - UC SEG状态不允许 - 0003状态。下面是我的CURL请求标头和代码。 CURL请求中的标题选项是否会产生问题?
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;
}
}
<?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">info@gandakiintl.com</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:x12.org.IO5:01">webservices.sabre.com</eb:PartyId>
</eb:To>
<eb:ConversationId>111@gandakiintl.com</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:11110info@gandakiintl.com</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>
<?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">info@gandakiintl.com</eb:PartyId>
</eb:To>
<eb:CPAId>T198</eb:CPAId>
<eb:ConversationId>111@gandakiintl.com</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:11110info@gandakiintl.com</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>
答案 0 :(得分:3)
我必须检查你的代码,有一件事是,如果你从邮递员那里得到你的结果..那么有一个很好的选择从邮递员获得卷曲代码。点击代码&gt;将HTTP选项更改为PHP curl&gt;复制到剪贴板。如果您尝试使用这种写代码方式,则必须更改少量更改。
还有一件事,这里给出了一个非常好的答案UC status。 UC状态与UN-CONFIRMED状态相关。请看这里。谢谢
这是一个例子,关于如何以xml格式传递你的帖子字段数据:
$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;
}
答案 1 :(得分:1)
我试过你的代码并修改了它的一部分。请尝试使用以下代码
<?php
header('Content-Type: application/xml');
$xmldata='<?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">info@gandakiintl.com</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:x12.org.IO5:01">webservices.sabre.com</eb:PartyId>
</eb:To>
<eb:ConversationId>111@gandakiintl.com</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:11110info@gandakiintl.com</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>';
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),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $wsdl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$err = curl_error($ch);
print_r($response);
print_r($err);
?>
答案 2 :(得分:0)
我不知道军刀api,但看起来你的请求与部门UC一致。
尝试查看api文档或尝试联系帮助台。
在示例请求中,没有<haltonstatus/>
,请看这里
https://developer.sabre.com/docs/read/soap_apis/air/book/orchestrated_air_booking
答案 3 :(得分:0)
UC状态表示您预订的行程不可用。这可能是由于许多不同的事情,如日期,服务等等。
您从哪里获得行程信息?如果您正在使用购物服务,我建议您再次运行它,看看是否仍然返回相同的行程,或者是否更改了服务等级。
答案 4 :(得分:0)
将xml内容写入名为soap_this.xml的文件,并使用curl命令发送请求:
curl -X POST --header "Content-Type:text/xml;charset=UTF-8" --data @soap_get.xml your_url
答案 5 :(得分:0)
这是因为在您创建pnr请求时,您的请求客舱类型可能没有可用的航班。即使至少有一个航班部门无法使用,Sabre也不允许创建pnr
使用以下Sabre命令,您可以检查航段的可用性
有关命令的更多详细信息:http://www.emquest.ae/downloads/STM/Quick%20Reference%20English.pdf
答案 6 :(得分:0)
在您的请求中,您已设置此选项:
<HaltOnStatus Code="UC"/>
<HaltOnStatus Code="LL"/>
<HaltOnStatus Code="UL"/>
<HaltOnStatus Code="UN"/>
<HaltOnStatus Code="NO"/>
<HaltOnStatus Code="HL"/>
这意味着如果由于可用性而未确认您要销售的细分市场,则结束交易。