【问题标题】:How do I make a SOAP request in a PHP file? [duplicate]如何在 PHP 文件中发出 SOAP 请求? [复制]
【发布时间】:2015-08-11 16:05:42
【问题描述】:

我想在 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>

【问题讨论】:

    标签: php xml web-services soap


    【解决方案1】:

    查看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 响应。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-25
    相关资源
    最近更新 更多