3

I'm trying to get a response from Travelports uAPI via XML/SOAP but i'm not just getting anything useful. print_r and var_dump and an echo all just show Resource id #2 which IS something but can't get any further.

I've tried their API Test Tool to send XML requests and it works fine but just can't get it to work in PHP. I've parsed XML before but never send requests.

Code:

<?php
$CREDENTIALS = '******************';
$message = '
<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<s:Body>
 <air:AvailabilitySearchReq TraceId="P107788" AuthorizedBy="User" TargetBranch="P107788" xmlns:air="http://www.travelport.com/schema/air_v23_0" xmlns:com="http://www.travelport.com/schema/common_v20_0">
  <com:BillingPointOfSaleInfo OriginApplication="UAPI" /> 
 <air:SearchAirLeg>
 <air:SearchOrigin>
  <com:Airport Code="SYD" /> 
  </air:SearchOrigin>
 <air:SearchDestination>
  <com:Airport Code="MEL" /> 
  </air:SearchDestination>
  <air:SearchDepTime PreferredTime="2013-12-30" /> 
  </air:SearchAirLeg>
 <air:SearchAirLeg>
 <air:SearchOrigin>
  <com:Airport Code="MEL" /> 
  </air:SearchOrigin>
 <air:SearchDestination>
  <com:Airport Code="SYD" /> 
  </air:SearchDestination>
  <air:SearchDepTime PreferredTime="2014-01-02" /> 
  </air:SearchAirLeg>
 <air:AirSearchModifiers>
 <air:PreferredProviders>
  <com:Provider Code="1P" />
  </air:PreferredProviders>
 <air:PreferredCarriers>
  <com:Carrier Code="QF" /> 
  </air:PreferredCarriers>
  </air:AirSearchModifiers>
  <com:SearchPassenger Code="ADT" /> 
  <com:SearchPassenger Code="ADT" /> 
  </air:AvailabilitySearchReq>
  </s:Body>
  </s:Envelope>
';

$auth = $CREDENTIALS; //should base_64_encode() this!
$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/Service"); 
$header = array( 
"Content-Type: text/xml;charset=UTF-8",
"Accept: gzip,deflate",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"\"", 
"Authorization: Basic $auth",
"Content-length: ".strlen($message),
); 
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 60); 
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, $message);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_exec($soap_do);



print_r($soap_do); echo '<br>';
var_dump($soap_do);
echo '<br>'.$soap_do;

?>

Any help just to get me started would be great. :)

4

2 回答 2

4

我是 Travelport 的合作伙伴技术专家,我理解您的沮丧。我们之前对端点的使用和描述一直令人困惑。如果您登录我们的开发者门户,将会有更新的 PHP 示例; https://developer.travelport.com/app/developer-network/resource-centre-uapi

最简单的是“取消全选”,然后专门为“示例代码”选择。

试试看!

于 2014-05-08T14:57:16.800 回答
2

只是改变

$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/Service");

$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/AirService");

于 2013-10-04T04:31:52.863 回答