class SoapServer (View source)

The SoapServer class provides a server for the SOAP 1.1 and SOAP 1.2 protocols. It can be used with or without a WSDL service description.

Methods

__construct(mixed $wsdl, array $options = [])

SoapServer constructor

SoapServer(mixed $wsdl, array $options = null)

SoapServer constructor

void
setPersistence(int $mode)

Sets SoapServer persistence mode

void
setClass(string $class, mixed ...$args)

Sets the class which handles SOAP requests

void
setObject(object $object)

Sets the object which will be used to handle SOAP requests

void
addFunction(mixed $functions)

Adds one or more functions to handle SOAP requests

array
getFunctions()

Returns list of defined functions

void
handle(string $request = null)

Handles a SOAP request

void
fault(string $code, string $string, string $actor = '', string $details = null, string $name = '')

Issue SoapServer fault indicating an error

void
addSoapHeader(SoapHeader $header)

Add a SOAP header to the response

string|null
__getLastResponse()

No description

Details

__construct(mixed $wsdl, array $options = [])

Since: 5.0.1

SoapServer constructor

Parameters

mixed $wsdl

To use the SoapServer in WSDL mode, pass the URI of a WSDL file. Otherwise, pass NULL and set the uri option to the target namespace for the server.

array $options

[optional]

Allow setting a default SOAP version (soap_version), internal character encoding (encoding), and actor URI (actor).

The classmap option can be used to map some WSDL types to PHP classes. This option must be an array with WSDL types as keys and names of PHP classes as values.

The typemap option is an array of type mappings. Type mapping is an array with keys type_name, type_ns (namespace URI), from_xml (callback accepting one string parameter) and to_xml (callback accepting one object parameter).

The cache_wsdl option is one of WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY or WSDL_CACHE_BOTH.

There is also a features option which can be set to SOAP_WAIT_ONE_WAY_CALLS, SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE.

SoapServer(mixed $wsdl, array $options = null)

Since: 5.0.1

SoapServer constructor

Parameters

mixed $wsdl

To use the SoapServer in WSDL mode, pass the URI of a WSDL file. Otherwise, pass NULL and set the uri option to the target namespace for the server.

array $options

[optional]

Allow setting a default SOAP version (soap_version), internal character encoding (encoding), and actor URI (actor).

The classmap option can be used to map some WSDL types to PHP classes. This option must be an array with WSDL types as keys and names of PHP classes as values.

The typemap option is an array of type mappings. Type mapping is an array with keys type_name, type_ns (namespace URI), from_xml (callback accepting one string parameter) and to_xml (callback accepting one object parameter).

The cache_wsdl option is one of WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY or WSDL_CACHE_BOTH.

There is also a features option which can be set to SOAP_WAIT_ONE_WAY_CALLS, SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE.

void setPersistence(int $mode)

Since: 5.1.2

Sets SoapServer persistence mode

Parameters

int $mode

One of the SOAP_PERSISTENCE_XXX constants.

SOAP_PERSISTENCE_REQUEST - SoapServer data does not persist between requests. This is the default behavior of any SoapServer object after setClass is called.

SOAP_PERSISTENCE_SESSION - SoapServer data persists between requests. This is accomplished by serializing the SoapServer class data into $_SESSION['_bogus_session_name'], because of this session_start must be called before this persistence mode is set.

Return Value

void

No value is returned.

void setClass(string $class, mixed ...$args)

Since: 5.0.1

Sets the class which handles SOAP requests

Parameters

string $class

The name of the exported class.

mixed ...$args

[optional] These optional parameters will be passed to the default class constructor during object creation.

Return Value

void

No value is returned.

void setObject(object $object)

Sets the object which will be used to handle SOAP requests

Parameters

object $object

The object to handle the requests.

Return Value

void

No value is returned.

void addFunction(mixed $functions)

Since: 5.0.1

Adds one or more functions to handle SOAP requests

Parameters

mixed $functions

To export one function, pass the function name into this parameter as a string.

To export several functions, pass an array of function names.

To export all the functions, pass a special constant SOAP_FUNCTIONS_ALL.

functions must receive all input arguments in the same order as defined in the WSDL file (They should not receive any output parameters as arguments) and return one or more values. To return several values they must return an array with named output parameters.

Return Value

void

No value is returned.

array getFunctions()

Since: 5.0.1

Returns list of defined functions

Return Value

array

An array of the defined functions.

void handle(string $request = null)

Since: 5.0.1

Handles a SOAP request

Parameters

string $request

[optional]

The SOAP request. If this argument is omitted, the request is assumed to be in the raw POST data of the HTTP request.

Return Value

void

No value is returned.

void fault(string $code, string $string, string $actor = '', string $details = null, string $name = '')

Since: 5.0.1

Issue SoapServer fault indicating an error

Parameters

string $code

The error code to return

string $string

A brief description of the error

string $actor

[optional]

A string identifying the actor that caused the fault.

string $details

[optional]

More details of the fault

string $name

[optional]

The name of the fault. This can be used to select a name from a WSDL file.

Return Value

void

No value is returned.

void addSoapHeader(SoapHeader $header)

Since: 5.0.1

Add a SOAP header to the response

Parameters

SoapHeader $header

The header to be returned.

Return Value

void

No value is returned.

string|null __getLastResponse()

Since: 8.4

No description

Return Value

string|null