我是SOAP新手。我正在与需要以下请求的Web服务组织合作:
POST /bookingapi.asmx HTTP/1.1
Host: bookingapitest.globusfamily.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://globusfamily.com/api/booking/ws/internal/GVI_DepartureInfo"
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<GVI_DepartureInfo xmlns="http://globusfamily.com/api/booking/ws/internal">
<GVI_DepartureInfoRequest VendorId="string" VendorPassword="string" xmlns="http://globusfamily.com/api/booking/departureinforequest">
<Brand>string</Brand>
<TourCode>string</TourCode>
<DepartureCode>string</DepartureCode>
</GVI_DepartureInfoRequest>
</GVI_DepartureInfo>
</soap:Body>
</soap:Envelope>
但是我无法让它发挥作用。我尝试过以下方法:
function test_booking_globus_soap_connect() {
$serviceWsdl = 'https://bookingapitest.globusfamily.com/bookingapi.asmx?WSDL';
$serviceParams = array(
'login' => "logind",
'password' => "pw"
);
$client = new SoapClient($serviceWsdl, $serviceParams);
$data['Brand'] = "All";
$data['TourCode'] = "QBE";
$data['DepartureCode'] = "800040321";
$data['VendorId'] = "test";
$data['VendorPassword'] = "test";
$results = $client->GVI_DepartureInfo($data);
}
我缺少什么?请帮忙。 我收到此错误: 致命错误:未捕获的SoapFault异常:[q0:安全]不满足安全要求,因为传入消息中不存在安全标头。
答案 0 :(得分:0)
这是一个迟到的回应,但也许它会帮助别人。
您需要在请求中包含安全标头。
用户名和密码是代理商ID和密码。
以下是示例:
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>string</Username>
<Password>string</Password>
</UsernameToken>
</Security>
</soap:Header>
<soap:Body>
<GVI_DepartureInfo xmlns="http://globusfamily.com/api/booking/ws/internal">
<GVI_DepartureInfoRequest VendorId="string" VendorPassword="string" xmlns="http://globusfamily.com/api/booking/departureinforequest">
<Brand>string</Brand>
<TourCode>string</TourCode>
<DepartureCode>string</DepartureCode>
</GVI_DepartureInfoRequest>
</GVI_DepartureInfo>
</soap:Body>
</soap:Envelope>