Herong's Tutorial Notes on Web Service and SOAP
Dr. Herong Yang, Version 4.00

PHP SOAP Extension Functions for Client Programs

This section describes client side functions of the PHP SOAP Extension.

If you read the SOAP Extension reference page, you will see that SOAP Extension support SOAP client applications with a class called SoapClient, which offers the following functions:

  • SoapClient->__construct() - constructs a new SoapClient object
  • SoapClient->__soapCall() - Calls a SOAP function
  • SoapClient->__getFunctions() - Returns list of SOAP functions
  • SoapClient->__getLastRequestHeaders() - Returns last SOAP request headers
  • SoapClient->__getLastRequest() - Returns last SOAP request
  • SoapClient->__getLastResponseHeaders() - Returns last SOAP response headers
  • SoapClient->__getLastResponse() - Returns last SOAP response
  • ...

SoapClient->__construct() allows you to construct a new SoapClient object with the following syntax:

   __construct ( mixed wsdl [, array options] );

where "wsdl" specifies the URL of the WSDL document, and "options" specifies a list of options:

   'location'     => "...", # the URL where to send the request
   'uri'          => "...", # the name space of the SOAP service
   'soap_version' => SOAP_1_1 |SOAP_1_2,
   'trace'        => 0 | 1,
   ... 

Note that SoapClient object can be constructed in two modes, WSDL mode and non-WSDL mode:

   __construct( "..."[, array options] ); # WSDL mode, many options
      # are provided by the WSDL document
   __construct( null, array options ); # non-WSDL mode, 'location'
      # and 'uri' are required options. 

SoapClient->__getFunctions() allows you to get a list of functions supported by the target node. This function is only valid in WSDL mode:

   array $a = $obj->__getFunctions();

SoapClient->__soapCall() allows you to make a RPC function call on the target SOAP node.

   $obj->__soapCall(string func_name[, array arguments [, ...]]);

Note that in WSDL mode, you can also make a RPC call as a local method on the SoapClient object:

   $obj->func_name(arg1, arg2, ...);

SoapClient->__getLastRequestHeaders() allows you to retrieve the HTTP request header lines of the last SOAP request executed. This function works only if the SoapClient object was created with the option of "trace=1".

   string $s = $obj->__getLastRequestHeaders();

SoapClient->__getLastRequest() allows you to retrieve SOAP request message of the last SOAP request executed. This function works only if the SoapClient object was created with the option of "trace=1".

   string $s = $obj->__getLastRequest();

SoapClient->__getLastResponseHeaders() allows you to retrieve the HTTP response header lines of the last SOAP request executed. This function works only if the SoapClient object was created with the option of "trace=1".

   string $s = $obj->__getLastRequestHeaders();

SoapClient->__getLastResponse() allows you to retrieve SOAP response message of the last SOAP request executed. This function works only if the SoapClient object was created with the option of "trace=1".

   string $s = $obj->__getLastResponse();

Last update: 2007.

Sections in This Chapter

What Is PHP SOAP Extension?

GetTemp.php - First Example with SOAP

PHP SOAP Extension Functions for Client Programs

GetTempDump.php - Dumping Debugging Information

Whis Is WSDL (Web Services Definition Language)?

Using SOAP Extension in non-WDSL Mode

Dr. Herong Yang, updated in 2009
PHP SOAP Extension Functions for Client Programs