SOAP Client
suggest changeVersions
The SOAP extension has been available since PHP 5.0.
Syntax
- __getFunctions() // Returns array of functions for service (WSDL mode only)
- __getTypes() // Returns array of types for service (WSDL mode only)
- __getLastRequest() // Returns XML from last request (Requires
traceoption) - __getLastRequestHeaders() // Returns headers from last request (Requires
traceoption) - __getLastResponse() // Returns XML from last response (Requires
traceoption) - __getLastResponseHeaders() // Returns headers from last response (Requires
traceoption)
Parameters
| Parameter | Details |
|---|---|
$wsdl |
URI of WSDL or NULL if using non-WSDL mode |
$options |
Array of options for SoapClient. Non-WSDL mode requires location and uri to be set. All other options are optional. See the 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):
| Option | Details |
|---|---|
location |
URL of SOAP server. Required in non-WSDL mode. Can be used in WSDL mode to override the URL. |
uri |
Target namespace of the SOAP service. Required in non-WSDL mode. |
style |
Possible values are SOAP_RPC or SOAP_DOCUMENT. Only valid in non-WSDL mode. |
use |
Possible values are SOAP_ENCODED or SOAP_LITERAL. Only valid in non-WSDL mode. |
soap_version |
Possible values are SOAP_1_1 (default) or SOAP_1_2. |
authentication |
Enable HTTP authentication. Possible values are SOAP_AUTHENTICATION_BASIC (default) or SOAP_AUTHENTICATION_DIGEST. |
login |
Username for HTTP authentication |
password |
Password for HTTP authentication |
proxy_host |
URL of proxy server |
proxy_port |
Proxy server port |
proxy_login |
Username for proxy |
proxy_password |
Password for proxy |
local_cert |
Path to HTTPS client certificate (for authentication) |
passphrase |
Passphrase for the HTTPS client certificate |
compression |
Compress request and 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. |
encoding |
Internal character encoding. SOAP requests stay UTF-8; PHP strings are converted to it. |
trace |
Boolean, defaults to FALSE. Enables tracing of requests so faults can be backtraced. Enables __getLastRequest(), __getLastRequestHeaders(), __getLastResponse(), and __getLastResponseHeaders(). |
classmap |
Map WSDL types to PHP classes. Value should be an array with WSDL types as keys and PHP class names as values. |
exceptions |
Boolean. Whether SOAP errors throw exceptions of type SoapFault. |
connection_timeout |
Timeout (in seconds) for the connection to the SOAP service. |
typemap |
Array of type mappings. Each entry has type_name, type_ns (namespace URI), from_xml (callback accepting one string), and to_xml (callback accepting one object). |
cache_wsdl |
How (if at all) the WSDL file should be cached. Possible values are WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY, or WSDL_CACHE_BOTH. |
user_agent |
String to use in the User-Agent header. |
stream_context |
A stream-context resource. |
features |
Bitmask of SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE, SOAP_WAIT_ONE_WAY_CALLS. |
keep_alive |
(PHP 5.4 and later) Boolean. Send either a Connection: Keep-Alive header (TRUE) or a Connection: Close header (FALSE). |
ssl_method |
(PHP 5.5 and later) 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. SSLv2 and SSLv3 are obsolete. |
Issue with 32-bit PHP: on 32-bit builds, numeric strings longer than 32 bits that
xs:longcasts to integer become2147483647. Cast the strings to float before passing them to__soapCall().
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents