Zend Framework  2.4
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Server Class Reference

Public Member Functions

 __construct ($wsdl=null, array $options=null)
 Constructor.
 
 setOptions ($options)
 Set Options.
 
 getOptions ()
 Return array of options suitable for using with SoapServer constructor.
 
 setEncoding ($encoding)
 Set encoding.
 
 getEncoding ()
 Get encoding.
 
 setSoapVersion ($version)
 Set SOAP version.
 
 getSoapVersion ()
 Get SOAP version.
 
 validateUrn ($urn)
 Check for valid URN.
 
 setActor ($actor)
 Set actor.
 
 getActor ()
 Retrieve actor.
 
 setUri ($uri)
 Set URI.
 
 getUri ()
 Retrieve URI.
 
 setClassmap ($classmap)
 Set classmap.
 
 getClassmap ()
 Retrieve classmap.
 
 setTypemap ($typeMap)
 Set typemap with xml to php type mappings with appropriate validation.
 
 getTypemap ()
 Retrieve typemap.
 
 setWSDL ($wsdl)
 Set wsdl.
 
 getWSDL ()
 Retrieve wsdl.
 
 setSoapFeatures ($feature)
 Set the SOAP Feature options.
 
 getSoapFeatures ()
 Return current SOAP Features options.
 
 setWSDLCache ($options)
 Set the SOAP WSDL Caching Options.
 
 getWSDLCache ()
 Get current SOAP WSDL Caching option.
 
 addFunction ($function, $namespace= '')
 Attach a function as a server method.
 
 setClass ($class, $namespace= '', $argv=null)
 Attach a class to a server.
 
 setObject ($object)
 Attach an object to a server.
 
 getFunctions ()
 Return a server definition array.
 
 loadFunctions ($definition)
 Unimplemented: Load server definition.
 
 setPersistence ($mode)
 Set server persistence.
 
 getPersistence ()
 Get server persistence.
 
 getLastRequest ()
 Retrieve request XML.
 
 setReturnResponse ($flag=true)
 Set return response flag.
 
 getReturnResponse ()
 Retrieve return response flag.
 
 getResponse ()
 Get response XML.
 
 getSoap ()
 Get SoapServer object.
 
 handle ($request=null)
 Proxy for _getSoap method.
 
 setDebugMode ($debug)
 Set the debug mode.
 
 registerFaultException ($class)
 Validate and register fault exception.
 
 isRegisteredAsFaultException ($fault)
 Checks if provided fault name is registered as valid in this server.
 
 deregisterFaultException ($class)
 Deregister a fault exception from the fault exception stack.
 
 getFaultExceptions ()
 Return fault exceptions list.
 
 getException ()
 Return caught exception during business code execution.
 
 fault ($fault=null, $code= 'Receiver')
 Generate a server fault.
 
 handlePhpErrors ($errno, $errstr, $errfile=null, $errline=null, array $errcontext=null)
 Throw PHP errors as SoapFaults.
 

Protected Member Functions

 _setRequest ($request)
 Set request.
 
 _initializeSoapErrorContext ()
 Method initializes the error context that the SOAPServer environment will run in.
 

Protected Attributes

 $actor
 
 $class
 
 $server = null
 
 $classArgs = array()
 
 $classmap
 
 $encoding
 
 $faultExceptions = array()
 
 $caughtException = null
 
 $features
 
 $functions = array()
 
 $object
 Object registered with this server.
 
 $debug = false
 
 $persistence
 
 $request
 
 $response
 
 $returnResponse = false
 
 $soapVersion = SOAP_1_2
 
 $typemap
 
 $uri
 
 $wsdl
 
 $wsdlCache
 

Constructor & Destructor Documentation

__construct (   $wsdl = null,
array  $options = null 
)

Constructor.

Sets display_errors INI setting to off (prevent client errors due to bad XML in response). Registers handlePhpErrors() as error handler for E_USER_ERROR.

If $wsdl is provided, it is passed on to setWSDL(); if any options are specified, they are passed on to setOptions().

Parameters
string$wsdl
array$options
Exceptions
Exception\ExtensionNotLoadedException

Member Function Documentation

_initializeSoapErrorContext ( )
protected

Method initializes the error context that the SOAPServer environment will run in.

Returns
bool display_errors original value
_setRequest (   $request)
protected

Set request.

$request may be any of:

  • DOMDocument; if so, then cast to XML
  • DOMNode; if so, then grab owner document and cast to XML
  • SimpleXMLElement; if so, then cast to XML
  • stdClass; if so, calls __toString() and verifies XML
  • string; if so, verifies XML
Parameters
DOMDocument | DOMNode | SimpleXMLElement | \stdClass | string$request
Returns
self
Exceptions
Exception\InvalidArgumentException
addFunction (   $function,
  $namespace = '' 
)

Attach a function as a server method.

Parameters
array | string$functionFunction name, array of function names to attach, or SOAP_FUNCTIONS_ALL to attach all functions
string$namespaceIgnored
Returns
self
Exceptions
Exception\InvalidArgumentExceptionon invalid functions

Implements Server.

deregisterFaultException (   $class)

Deregister a fault exception from the fault exception stack.

Parameters
string$class
Returns
bool
fault (   $fault = null,
  $code = 'Receiver' 
)

Generate a server fault.

Note that the arguments are reverse to those of SoapFault.

If an exception is passed as the first argument, its message and code will be used to create the fault object if it has been registered via { registerFaultException()}.

string| $fault string $code SOAP Fault Codes SoapFault

Implements Server.

getActor ( )

Retrieve actor.

Returns
string
getClassmap ( )

Retrieve classmap.

Returns
mixed
getEncoding ( )

Get encoding.

Returns
string
getException ( )

Return caught exception during business code execution.

Returns
null| caught exception
getFaultExceptions ( )

Return fault exceptions list.

Returns
array
getFunctions ( )

Return a server definition array.

Returns a list of all functions registered with addFunction(), merged with all public methods of the class set with setClass() (if any).

Returns
array

Implements Server.

getLastRequest ( )

Retrieve request XML.

Returns
string
getOptions ( )

Return array of options suitable for using with SoapServer constructor.

Returns
array
getPersistence ( )

Get server persistence.

Returns
int
getResponse ( )

Get response XML.

Returns
string

Implements Server.

getReturnResponse ( )

Retrieve return response flag.

Returns
bool

Implements Server.

getSoap ( )

Get SoapServer object.

Uses $wsdl and return value of getOptions() to instantiate SoapServer object, and then registers any functions or class with it, as well as persistence.

Returns
SoapServer
getSoapFeatures ( )

Return current SOAP Features options.

Returns
int
getSoapVersion ( )

Get SOAP version.

Returns
int
getTypemap ( )

Retrieve typemap.

Returns
array
getUri ( )

Retrieve URI.

Returns
string
getWSDL ( )

Retrieve wsdl.

Returns
string
getWSDLCache ( )

Get current SOAP WSDL Caching option.

handle (   $request = null)

Proxy for _getSoap method.

See Also
_getSoap
Returns
SoapServer the soapServer instance public function getSoap() { return $this->_getSoap(); } Handle a request

Instantiates SoapServer object with options set in object, and dispatches its handle() method.

$request may be any of:

  • DOMDocument; if so, then cast to XML
  • DOMNode; if so, then grab owner document and cast to XML
  • SimpleXMLElement; if so, then cast to XML
  • stdClass; if so, calls __toString() and verifies XML
  • string; if so, verifies XML

If no request is passed, pulls request using php:://input (for cross-platform compatibility purposes).

Parameters
DOMDocument | DOMNode | SimpleXMLElement | \stdClass | string$requestOptional request
Returns
void|string

Implements Server.

handlePhpErrors (   $errno,
  $errstr,
  $errfile = null,
  $errline = null,
array  $errcontext = null 
)

Throw PHP errors as SoapFaults.

Parameters
int$errno
string$errstr
string$errfile
int$errline
array$errcontext
Exceptions
SoapFault
isRegisteredAsFaultException (   $fault)

Checks if provided fault name is registered as valid in this server.

Parameters
string$faultName of a fault class
Returns
bool
loadFunctions (   $definition)

Unimplemented: Load server definition.

Parameters
array$definition
Exceptions
Exception\RuntimeExceptionUnimplemented

Implements Server.

registerFaultException (   $class)

Validate and register fault exception.

Parameters
string | array$classException class or array of exception classes
Returns
self
Exceptions
Exception\InvalidArgumentException
setActor (   $actor)

Set actor.

Actor is the actor URI for the server.

Parameters
string$actor
Returns
self
setClass (   $class,
  $namespace = '',
  $argv = null 
)

Attach a class to a server.

Accepts a class name to use when handling requests. Any additional arguments will be passed to that class' constructor when instantiated.

See setObject() to set pre-configured object instances as request handlers.

Parameters
string | object$classClass name or object instance which executes SOAP Requests at endpoint.
string$namespace
null | array$argv
Returns
self
Exceptions
Exception\InvalidArgumentExceptionif called more than once, or if class does not exist

Implements Server.

setClassmap (   $classmap)

Set classmap.

Parameters
array$classmap
Returns
self
Exceptions
Exception\InvalidArgumentExceptionfor any invalid class in the class map
setDebugMode (   $debug)

Set the debug mode.

In debug mode, all exceptions are send to the client.

Parameters
bool$debug
setEncoding (   $encoding)

Set encoding.

Parameters
string$encoding
Returns
self
Exceptions
Exception\InvalidArgumentExceptionwith invalid encoding argument
setObject (   $object)

Attach an object to a server.

Accepts an instantiated object to use when handling requests.

Parameters
object$object
Returns
self
Exceptions
Exception\InvalidArgumentException
setOptions (   $options)

Set Options.

Allows setting options as an associative array of option => value pairs.

Parameters
array | \Traversable$options
Returns
self
setPersistence (   $mode)

Set server persistence.

Parameters
int$modeSOAP_PERSISTENCE_SESSION or SOAP_PERSISTENCE_REQUEST constants
Returns
self
Exceptions
Exception\InvalidArgumentException

Implements Server.

setReturnResponse (   $flag = true)

Set return response flag.

If true, handle() will return the response instead of automatically sending it back to the requesting client.

The response is always available via getResponse().

Parameters
bool$flag
Returns
self

Implements Server.

setSoapFeatures (   $feature)

Set the SOAP Feature options.

Parameters
string | int$feature
Returns
self
setSoapVersion (   $version)

Set SOAP version.

Parameters
int$versionOne of the SOAP_1_1 or SOAP_1_2 constants
Returns
self
Exceptions
Exception\InvalidArgumentExceptionwith invalid soap version argument
setTypemap (   $typeMap)

Set typemap with xml to php type mappings with appropriate validation.

Parameters
array$typeMap
Returns
self
Exceptions
Exception\InvalidArgumentException
setUri (   $uri)

Set URI.

URI in SoapServer is actually the target namespace, not a URI; $uri must begin with 'urn:'.

Parameters
string$uri
Returns
self
setWSDL (   $wsdl)

Set wsdl.

Parameters
string$wsdlURI or path to a WSDL
Returns
self
setWSDLCache (   $options)

Set the SOAP WSDL Caching Options.

Parameters
string | int | bool$options
Returns
self
validateUrn (   $urn)

Check for valid URN.

Parameters
string$urn
Returns
true
Exceptions
Exception\InvalidArgumentExceptionon invalid URN

Member Data Documentation

$actor
protected
$caughtException = null
protected
$class
protected
$classArgs = array()
protected
$classmap
protected
$debug = false
protected
$encoding
protected
$faultExceptions = array()
protected
$features
protected
$functions = array()
protected
$object
protected

Object registered with this server.

$persistence
protected
$request
protected
$response
protected
$returnResponse = false
protected
$server = null
protected
$soapVersion = SOAP_1_2
protected
$typemap
protected
$uri
protected
$wsdl
protected
$wsdlCache
protected