使用 php soapClient 访问 Travelport uAPI 时遇到问题。
能够使用 Curl 取回数据,但无法使用 Air.wsdl 文件访问 Travelport。
当前使用 2015 年 7 月 1 日发布的最新 Air.wsdl 文件。
任何人都有一个关于如何完成的工作示例?
Travelport提供者:
namespace Providers;
use Providers\Clients\SoapClient;
class TravelportProvider extends SoapClient
{
public function __construct() {
parent::__construct(config('travelport.airWsdl'), config('travelport.endpoint'));
}
public function search()
{
return $this->service();
}
public function service() {
$parameters = array(
'BillingPointOfSaleInfo' => array(
'OriginApplication' => 'UAPI'
),
'AirPricingSolution' => array(
'Key' => 1
),
'legs' => array(
'Key' => 1,
'Group' => 1,
'Origin' => 'BNE',
'Destination' => 'SYD',
'departureDate' => '2015-07-23',
'cabinClass' => 'Economy',
'validationPassed:protected' => '1',
'validationErrors:protected' => ''
)
);
$response = $this->__soapCall('service', array($parameters));
return $response;
}
}
肥皂客户端:
namespace Providers\Clients;
abstract class SoapClient extends \SoapClient
{
/**
* Configuration Array
*
* @var array
*/
protected $config = null;
/**
* Options Array
*
* @var array
*/
protected $options = null;
public function __construct($wsdl, $endpoint, $options = null) {
// Set Soap Config
$this->setConfig($wsdl, $endpoint);
// Set Soap Context
$this->setContext();
// Create Classmap Array
// $this->setClassmap();
// Set Soap options
$this->setOptions($this->config, $this->context);
// Set the WSDL endpoint
$this->__setLocation($endpoint);
// Create the SoapClient
parent::__construct($wsdl, $this->options);
}
/**
* Set Soap Config
*
* @param string $wsdl
* @param string $endpoint
* @return array $config
*/
protected function setConfig($wsdl, $endpoint) {
// Check WSDL
if ($wsdl == null) {
throw new \SoapException("WSDL cannot be null");
}
// Credentials
$this->config = array(
'username' => config('travelport.username'),
'password' => config('travelport.password'),
'credentials' => config('travelport.credentials'),
'wsdl' => $wsdl,
'endpoint' => $endpoint
);
// Setting config
return $this->config;
}
/**
* Set Soap Context
*
* @return array $context
*/
protected function setContext() {
$this->context = array(
'http' => array(
'header' => array(
'Content-Type: text / xml; charset = UTF-8',
'Accept-Encoding: gzip, deflate',
'SOAPAction: ""'
)),
'ssl' => array(
'ciphers' => 'RC4-SHA'
)
);
return $this->context;
}
/**
* Set Soap Options
*
* @param array $config
* @param array $context
* @return array $options
*/
protected function setOptions($config, $context)
{
$this->options = array(
'soap_version' => 'SOAP_1_1',
'encoding' => 'UTF-8',
'exceptions' => true,
'stream_context' => stream_context_create($context),
'trace' => true,
'login' => $config['username'],
'password' => $config['password']
);
// Setting options
return $this->options;
}
}
我发现有趣的是最新的 Air.wsdl 文件具有相同的操作名称“服务”和相同的输入/输出名称。我要如何选择要搜索 LowFareSearch 的目标?
我做了一个 $this->__getfunction() ,我得到以下
Array
(
[0] => AirRepriceRsp service(AirRepriceReq $parameters)
[1] => ScheduleSearchRsp service(ScheduleSearchReq $parameters)
[2] => LowFareSearchRsp service(LowFareSearchReq $parameters)
[3] => LowFareSearchAsynchRsp service(LowFareSearchAsynchReq $parameters)
[4] => RetrieveLowFareSearchRsp service(RetrieveLowFareSearchReq $parameters)
[5] => AirPriceRsp service(AirPriceReq $parameters)
[6] => AirFareRulesRsp service(AirFareRulesReq $parameters)
[7] => AvailabilitySearchRsp service(AvailabilitySearchReq $parameters)
[8] => AirFareDisplayRsp service(AirFareDisplayReq $parameters)
[9] => SeatMapRsp service(SeatMapReq $parameters)
[10] => AirRefundQuoteRsp service(AirRefundQuoteReq $parameters)
[11] => AirRefundRsp service(AirRefundReq $parameters)
[12] => AirTicketingRsp service(AirTicketingReq $parameters)
[13] => AirVoidDocumentRsp service(AirVoidDocumentReq $parameters)
[14] => AirRetrieveDocumentRsp service(AirRetrieveDocumentReq $parameters)
[15] => AirExchangeRsp service(AirExchangeReq $parameters)
[16] => AirExchangeQuoteRsp service(AirExchangeQuoteReq $parameters)
[17] => AirExchangeTicketingRsp service(AirExchangeTicketingReq $parameters)
[18] => AirMerchandisingOfferAvailabilityRsp service(AirMerchandisingOfferAvailabilityReq $parameters)
[19] => AirUpsellSearchRsp service(AirUpsellSearchReq $parameters)
[20] => FlightTimeTableRsp service(FlightTimeTableReq $parameters)
[21] => AirPrePayRsp service(AirPrePayReq $parameters)
[22] => EMDRetrieveRsp service(EMDRetrieveReq $parameters)
[23] => EMDIssuanceRsp service(EMDIssuanceReq $parameters)
[24] => AirMerchandisingDetailsRsp service(AirMerchandisingDetailsReq $parameters)
[25] => FlightInformationRsp service(FlightInformationReq $parameters)
[26] => FlightDetailsRsp service(FlightDetailsReq $parameters)
)