SCA for PHP can generate WSDL from the annotations within a
service component, so that it can be easily deployed and exposed as a
Web service. To provide SCA with the information it needs to
generate the WSDL, it is necessary to add the annotation
@binding.soap under the @service annotation and to specify the
parameters and return values of the methods using the @param and
@return annotations. These annotations will be read when WSDL is
generated, and the order and types of the parameters determine the
contents of the
<schema> section of the WSDL.
SCA for PHP always generates document/literal wrapped WSDL
for components that are exposing a Web service. Note that this does
not stop components from consuming Web services which are not SCA
components and which are documented with WSDL written in a
different style.
The scalar types which can be used in the @param annotation are
the four common PHP scalar types: boolean, integer, float and
string. These are simply mapped to the XML schema types of the same
name in the WSDL. The example below, which is a trivial
implementation of the StockQuote service that the
ConvertedStockQuote component calls, illustrates string and
float types.
Example #1 StockQuote Service
<?php
include "SCA/SCA.php";
/** * Scaffold implementation for a remote StockQuote Web service. * * @service * @binding.soap * */ class StockQuote {
/** * Get a stock quote for a given ticker symbol. * * @param string $ticker The ticker symbol. * @return float The stock quote. */ function getQuote($ticker) { return 80.9; } } ?>
WSDL much like the following (though with a service location
other than 'localhost', probably) would be generated from this
service: