From 85a3fc6fb132d0f9dd31798d507cce77a33d87d9 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 8 Jan 2007 19:27:34 +0000 Subject: Added TSoapService tutorial page. --- .../protected/pages/Services/SoapService.page | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 demos/quickstart/protected/pages/Services/SoapService.page (limited to 'demos/quickstart/protected/pages/Services') diff --git a/demos/quickstart/protected/pages/Services/SoapService.page b/demos/quickstart/protected/pages/Services/SoapService.page new file mode 100644 index 00000000..59042156 --- /dev/null +++ b/demos/quickstart/protected/pages/Services/SoapService.page @@ -0,0 +1,74 @@ + + +

SOAP Service

+ +

+SOAP forms the foundation layer of the Web services stack. It provides a neat way for PHP applications to communicate with each other or with applications written in other languages. PRADO provides TSoapService that makes developing a SOAP server application an extremely easy task. +

+ +

+To use TSoapService, configure it in the application specification like following: +

+ + + + + + + + +

+The example specifies a SOAP service provider named stockquote which implements the getPrice SOAP method in the provider class StockQuote, +

+ +class StockQuote +{ + /** + * @param string $symbol the symbol of the stock + * @return float the stock price + * @soapmethod + */ + public function getPrice($symbol) + { + ....return stock price for $symbol + } +} + + +
Note: +TSoapService is based on PHP SOAP extension and thus requires the extension to be installed. +
+ +

+With the above simple code, we already finish a simple SOAP service that allows other applications to query the price of a specific stock. For example, a typical SOAP client may be written as follows to query the stock price of IBM, +

+ +$client=new SoapClient('http://path/to/index.php?soap=stockquote.wsdl'); +echo $client->getPrice('IBM'); + + +

+Notice the URL used to construct SoapClient (a class provided by PHP SOAP extension). This is the URL for the WSDL that describes the communication protocol for the SOAP service we just implemented. WSDL is often too complex to be manually written. Fortunately, TSoapService can generate this for us using a WSDL generator. In general, the URL for the automatically generated WSDL in PRADO has the following format: +

+ +http://path/to/index.php?SoapServiceID=SoapProviderID.wsdl + + +

+In order for the WSDL generator to generate WSDL for a SOAP service, the provider class needs to follow certain syntax. In particular, for methods to be exposed as SOAP methods, a keyword @soapmethod must appear in the phpdoc comment of the method with the following lines specifying method parameters and return value: +

+ +

+Valid parameter and return types include: string, int, boolean, float, array, mixed, etc. You may also specify a class name as the type, which translates into a complex SOAP type. +

+ +

+TSoapService may be configured and customized in several ways. In the example above, the <soap> element actually specifies a SOAP service using the default TSoapServer implementation. Attributes in <soap> are passed to TSoapServer as its initial property values. For example, the provider attribute initializes the Provider property of TSoapServer. By setting SessionPersistent to be true in <soap> element, the provider instance will persist within the user session. You may develop your own SOAP server class and use it by specifying the class attribute of <soap>. +

+ +
\ No newline at end of file -- cgit v1.2.3