12. Beyond HTML
* Introduction to QSoapService
<< Introduction to QI18n (Internationalization)   |   Back to Main   |   Next >>

View Source
will open in a new window
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: 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.
To view the webservice, please go to http://examples.qcodo.com/examples/communication/example_service.php
To use the webservice, use any SOAP compatible client and import the WSDL file at http://examples.qcodo.com/examples/communication/example_service.php?wsdl

Example call on ExampleService:

AddNumbers(15, 22):
37
GetDate(12, 25, 2007):
2007-12-25T00:00:00
(notice how the resulting QDateTime has been converted to a SOAP-compliant dateTime)
GetPeople('Smith'):