Stats

536 Contributors: 8 Wednesday, March 22, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

SOAP Client

Syntax

Parameters

ParameterDetails
$wsdlURI of WSDL or NULL if using non-WSDL mode
$optionsArray of options for SoapClient. Non-WSDL mode requires location and uri to set, all other options are optional. See table below for possible values.

Remarks

The SoapClient class is equipped with a __call method. This is not to be called directly. Instead this allows you to do:

$soap->requestInfo(['a', 'b', 'c']);

This will call the requestInfo SOAP method.


Table of possible $options values (Array of key/value pairs):

OptionDetails
locationURL of SOAP server. Required in non-WSDL mode. Can be used in WSDL mode to override the URL.
uriTarget namespace of SOAP service. Required in non-WSDL mode.
stylePossible values are SOAP_RPC or SOAP_DOCUMENT. Only valid in non-WSDL mode.
usePossible values are SOAP_ENCODED or SOAP_LITERAL. Only valid in non-WSDL mode.
soap_versionPossible values are SOAP_1_1 (default) or SOAP_1_2.
authenticationEnable HTTP authentication. Possible values are SOAP_AUTHENTICATION_BASIC (default) or SOAP_AUTHENTICATION_DIGEST.
loginUsername for HTTP authentication
passwordPassword for HTTP authentication
proxy_hostURL of proxy server
proxy_portProxy server port
proxy_loginUsername for proxy
proxy_passwordPassword for proxy
local_certPath to HTTPS client cert (for authentication)
passphrasePassphrase for HTTPS client cert
compressionCompress request / response. Value is a bitmask of SOAP_COMPRESSION_ACCEPT with either SOAP_COMPRESSION_GZIP or SOAP_COMPRESSION_DEFLATE. For example: SOAP_COMPRESSION_ACCEPT \| SOAP_COMPRESSION_GZIP.
encodingInternal character encoding (TODO: possible values)
traceBoolean, defaults to FALSE. Enables tracing of requests so faults can be backtraced. Enables use of __getLastRequest(), __getLastRequestHeaders(), __getLastResponse() and __getLastResponseHeaders().
classmapMap WSDL types to PHP classes. Value should be an array with WSDL types as keys and PHP class names as values.
exceptionsBoolean value. Should SOAP errors exceptions (of type `SoapFault).
connection_timeoutTimeout (in seconds) for the connection to the SOAP service.
typemapArray of type mappings. Array should be key/value pairs with the following keys: type_name, type_ns (namespace URI), from_xml (callback accepting one string parameter) and to_xml (callback accepting one object parameter).
cache_wsdlHow (if at all) should the WSDL file be cached. Possible values are WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY or WSDL_CACHE_BOTH.
user_agentString to use in the User-Agent header.
stream_contextA resource for a context.
featuresBitmask of SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE, SOAP_WAIT_ONE_WAY_CALLS.
keep_alive(PHP version >= 5.4 only) Boolean value. Send either Connection: Keep-Alive header (TRUE) or Connection: Close header (FALSE).
ssl_method(PHP version >= 5.5 only) Which SSL/TLS version to use. Possible values are SOAP_SSL_METHOD_TLS, SOAP_SSL_METHOD_SSLv2, SOAP_SSL_METHOD_SSLv3 or SOAP_SSL_METHOD_SSLv23.

Issue with 32 bit PHP: In 32 bit PHP, numeric strings greater than 32 bits which are automatically cast to integer by xs:long will result in it hitting the 32 bit limit, casting it to 2147483647. To work around this, cast the strings to float before passing it in to __soapCall().

Related Examples