如何在PHP文件中创建SOAP请求? [重复]

如何在PHP文件中创建SOAP请求?  [重复]

问题描述:

This question already has an answer here:

I want to make the following SOAP request in a PHP file, but I'm not sure how to implement it. Could someone explain how I would use this?

Also, how can I print out the result of the request stored in "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>
</div>

Check the manual for http://php.net/manual/en/soapclient.dorequest.php:

public string SoapClient::__doRequest ( string $request , string $location , string $action , int $version [, int $one_way = 0 ] ) performs SOAP request over HTTP.

Parameters:

request The XML SOAP request.

location The URL to request.

action The SOAP action.

version The SOAP version.

one_way If one_way is set to 1, this method returns nothing. Use this where a response is not expected.

Return:

The XML SOAP response.