Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1
CHAPTER 19 ■ INTRODUCTION TO WEB SERVICES WITH SOAP^293

SoapClient::__soapCall(string $operation, array $args
[, array $options, mixed $input_headers, array &$output_headers])

The arguments array may be an associative array of named parameters and values or a
numeric array of parameters. The options array allows you to define the soapaction and uri
options for when you’re working in non-WSDL mode or when you’re calling an operation in a
namespace other than the default. The input and output headers arrays are useful for passing
extra information, such as a session identifier or application authentication information.

■Caution If the service you are trying to interact with is a .NET service, it is sometimes necessary to place
an extra array level to enclose your arguments. To pass named parameters to a .NET service, the arguments
should be wrapped in an array key named parameters, as in array('parameters'=>array('a'=>1,
'b'=>2)).

The SoapClient class has several other useful methods and options that can be used when
interacting with remote web services, as listed in Table 19-2.

Table 19-2. Some Other SoapClient Methods
Method Description
SoapClient::__getLastRequest() Returns the last SOAP envelope that was
sent as a request. Requires that you enable
the trace option when constructing your
SoapClient class.
SoapClient::__getLastResponse() Returns the last SOAP envelope returned
from the web service. Requires the trace
option to be enabled.
SoapClient::__getLastRequestHeaders() Returns the SOAP headers that were sent
with the last request. Requires the trace
option to be enabled
SoapClient::__getLastResponseHeaders() Returns the SOAP headers that were
received with the last request. Also requires
the trace option to be enabled.
SoapClient::__getTypes() Returns a list of SOAP types defined by the
WSDL file.
SoapClient::__getFunctions() Retrieves a list of functions (operations)
that are defined by the WSDL file.
SoapClient::__setCookie(string $name [,
string $value])

An alternative to using SOAP headers, cookies
can be passed to the underlying HTTP trans-
port. On the server side, this information is
readable as a normal $_COOKIE variable.

McArthur_819-9.book Page 293 Friday, February 29, 2008 8:03 AM

Free download pdf