繁体   English   中英

使用PHP SoapClient的SOAP请求不起作用

[英]SOAP Request using PHP SoapClient not working

我是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:Security]由于传入消息中不存在安全头,因此不满足安全要求。

这是一个较晚的响应,但也许会对某人有所帮助。

您需要在请求中包含安全标头。

用户名和密码是代理机构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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM