Zend_Soap_ServerZend_Soap_Server class is intended to simplify Web Services server part development for PHP programmers. It may be used in WSDL or non-WSDL mode, and using classes or functions to define Web Service API. When Zend_Soap_Server component works in the WSDL mode, it uses already prepared WSDL document to define server object behavior and transport layer options. WSDL document may be auto-generated with functionality provided by Zend_Soap_AutoDiscovery component or should be constructed manually using Zend_Soap_Wsdl class or any other XML generating tool. If the non-WSDL mode is used, then all protocol options have to be set using options mechanism. Zend_Soap_Server constructorZend_Soap_Server constructor should be used a bit differently for WSDL and non-WSDL modes. Zend_Soap_Server constructor for the WSDL modeZend_Soap_Server constructor takes two optional parameters when it works in WSDL mode:
Zend_Soap_Server constructor for the non-WSDL modeThe first constructor parameter must be set to NULL if you plan to use Zend_Soap_Server functionality in non-WSDL mode. You also have to set 'uri' option in this case (see below). The second constructor parameter ($options) is an array with options to create SOAP server object [3] setOptions($options) . The following options are recognized in the non-WSDL mode:
Methods to define Web Service APIThere are two ways to define Web Service API when your want to give access to your PHP code through SOAP. The first one is to attach some class to the Zend_Soap_Server object which has to completely describe Web Service API:
The second method of defining Web Service API is using set of functions and addFunction() or loadFunctions() methods:
Request and response objects handling
Zend_Soap_Server component performs request/response processing automatically, but allows to catch it and do some pre- and post-processing. Request processingZend_Soap_Server::handle() method takes request from the standard input stream ('php://input'). It may be overridden either by supplying optional parameter to the handle() method or by setting request using setRequest() method:
Request object may be represented using any of the following:
Last processed request may be retrieved using getLastRequest() method as an XML string:
Response pre-processingZend_Soap_Server::handle() method automatically emits generated response to the output stream. It may be blocked using setReturnResponse() with TRUE or FALSE as a parameter [4] setReturnResponse() . Generated response is returned by handle() method in this case.
Last response may be also retrieved by getLastResponse() method for some post-processing:
[1]
May be set later using
method.
[2]
Options may be set later using
method.
[3]
Options may be set later using
method.
[4]
Current state of the Return Response flag may be requested with
method.
|