【发布时间】:2018-04-02 12:25:38
【问题描述】:
我正在我的在线旅行系统中实现 SOAP API,我正在尝试使用 curl request 获取 SOAP API 访问令牌。
我已经按照这篇文章 https://developer.sabre.com/resources/getting_started_with_sabre_apis/how_to_get_a_token#3sub4 使用我的 PCC 号码 "s6ci" 获取 SOAP API 访问令牌,但是当我运行该代码时,我得到空响应。
你能检查一下,让我知道我在这里做错了什么吗?
下面是我使用soap api使用的代码。
$environment = 'https://api.test.sabre.com';
// request string
$request = '<?xml version="1.0" encoding="utf-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap-env:Header>
<eb:MessageHeader soap-env:mustUnderstand="1" eb:version="1.0">
<eb:From>
<eb:PartyId />
</eb:From>
<eb:To>
<eb:PartyId />
</eb:To>
<eb:CPAId>s6ci</eb:CPAId>
<eb:ConversationId>V1@280b16ec-5eac-46c0-893f-c88f8e8cb632@310b16ec-5dad-46c0-893f-c88f8e8cb643@780b16ec-5eac-46c0-893f-c88f8e8cb699</eb:ConversationId>
<eb:Service>SessionCreateRQ</eb:Service>
<eb:Action>SessionCreateRQ</eb:Action>
<eb:MessageData />
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/12/utility">
<wsse:UsernameToken>
<wsse:Username>MyUsername</wsse:Username>
<wsse:Password>MyPassword</wsse:Password>
<Organization>s6ci</Organization>
<Domain />
</wsse:UsernameToken>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<eb:Manifest soap-env:mustUnderstand="1" eb:version="1.0">
<eb:Reference xlink:href="cid:rootelement" xlink:type="simple" />
</eb:Manifest>
<SessionCreateRQ>
<POS>
<Source PseudoCityCode="s6ci" />
</POS>
</SessionCreateRQ>
<ns:SessionCreateRQ xmlns:ns="http://www.opentravel.org/OTA/2002/11" />
</soap-env:Body>
</soap-env:Envelope>
';
//initialize curl request
$ch = curl_init($environment);
$headers = array(
'Content-Type: text/xml; charset=utf-8',
'Accept: text/xml',
"Content-Length: " . strlen($request)
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
// print response
echo 'Token '.$result;
exit;
$doc = new DOMDocument();
$doc->loadXML($result);
curl_close($ch);
return json_decode($result);
等待您的回复。
谢谢。 艾米·T
【问题讨论】:
标签: sabre