如何在PHP文件中创建SOAP请求?

时间:2015-08-11 16:05:43

标签: php xml web-services soap

我想在PHP文件中发出以下SOAP请求,但我不确定如何实现它。有人可以解释我会如何使用它?

另外,如何打印出" LoginSuccess"

中存储的请求的结果?
POST /soap/V200611.ASMX HTTP/1.1
Host: api.cvent.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <Login xmlns="http://api.cvent.com/2006-11">
      <AccountNumber>string</AccountNumber>
      <UserName>string</UserName>
      <Password>string</Password>
    </Login>
  </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <LoginResponse xmlns="http://api.cvent.com/2006-11">
      <LoginResult LoginSuccess="boolean" ServerURL="string" CventSessionHeader="string" ErrorMessage="string" xmlns="http://schemas.cvent.com/api/2006-11" />
    </LoginResponse>
  </soap12:Body>
</soap12:Envelope>

1 个答案:

答案 0 :(得分:0)

查看http://php.net/manual/en/soapclient.dorequest.php的手册:

public string SoapClient::__doRequest ( string $request , string $location , string $action , int $version [, int $one_way = 0 ] )通过HTTP执行SOAP请求。

参数:

请求 XML SOAP请求。

位置 要请求的URL。

<强>动作 SOAP动作。

版本 SOAP版本。

<强> one_way 如果one_way设置为1,则此方法不返回任何内容。在不期望响应的地方使用它。

返回:

XML SOAP响应。