使用PHP连接到示例SOAP 1.1

时间:2013-06-11 11:33:11

标签: php web-services soap

您好我需要在 php 中使用密码,用户名和SourceId连接到SOAP Web服务。 SOAP请求是:

POST /webservices/AgentOnlineReservation.asmx HTTP/1.1
Host: 54.228.189.53
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetHotelsData"

<?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>
    <GetHotelsData xmlns="http://tempuri.org/">
      <SourceId>string</SourceId>
      <UserName>string</UserName>
      <Password>string</Password>
    </GetHotelsData>
  </soap:Body>
</soap:Envelope> 

请帮帮我。

1 个答案:

答案 0 :(得分:8)

使用原生SoapClient库:

$client = new SoapClient('linkhere.com/AgentOnlineReservation.asmx?wsdl');

$response = $client->GetHotelsData(array(
    'SourceId' => '...',
    'UserName' => '...',
    'Password' => '...'
));

print_r($response);

SoapClient调用中传递的链接是WSDL(Web服务描述语言)文件。