SOAP Web Services
The Qcodo
QSoapService class allows you to very easily add SOAP-enabled
PHP methods to your application.
It utilizes the
SoapServer class in PHP 5.1 or greater
(and subsequently, this specific example also uses the
SoapClient class
to illustrate the
QSoapService in action).
However,
QSoapService adds a significant level of functionality,
overcoming most of the inherent issues found in the PHP
SoapServer, including:
- Full, Automatic WSDL Generation
- Supports parameters that are Pass By Reference
- Supports QDateTime, arrays and other input/output parameters that
are complex data structures
- And of course, full support for code generated data objects
To use, simply create a class which extends from
QSoapService, and define any
public methods as you would any other class (static, private and protected
methods can be defined in this class as well, but they will not be exposed as
publically available webservice methods).
Please note is that because SOAP by definition is a strongly-typed
protocol, and because PHP is not, you must declare the types of the input and output
parameters for each webservice-enabled method. This is done through standard
PHPDoc tags. Please view the code for
example_service.php for more information.
And finally, due to the heavy processing of WSDL generation, the results of the WSDL generation
are cached using
QCache, and cached files are stored in
/includes/cache/soap.