The examples in the subsequent sections illustrate the
following aspects of PHP for SCA:
How PHP annotations are used to define PHP classes as SCA
components, and how annotations are used to define the
services.
How an SCA component can be exposed as a Web service
How an SCA component can consume a Web service, whether
provided by another SCA component or by some other service which
knows nothing of SCA
How an SCA component can call another SCA component locally
(within the same process and on the same call stack)
How a client script which is not an SCA component can use the
getService call to obtain a proxy for an SCA component.
How data structures such as Addresses, or Puchase Orders,
are represented as Service Data Objects, and handled.
How SCA components are deployed, and in particular how and
when WSDL is generated for a service.
How parameters are always passed by value (and not by
reference) between components, even when the calls are local.
This ensures that the semantics of a call do not change depending on
the location of a component.
How positional parameters to a service are supported, even
when the underlying WSDL is document literal wrapped, and
naturally supports only named parameters.
How business and runtime exceptions are handled.
The structure of a Service Component
A service component is implemented by a class. To identify it
as a service component, it contains an @service annotation. The SCA
runtime will use the file name of the script to determine the
component name, by convention. The class and script file must
therefore share the same name.
PHP SCA components always expose a service, and there is no way
for a component to be invoked other than to be called as a result of a
Web service request, or called directly from another component or
from a script. For this reason a valid PHP SCA component will always
contain an @service annotation and at least one public method.
Each SCA Component requires that the SCA.php script is
included. As well as containing the definition of the SCA class,
this script contains executable PHP code that will run whenever the
script is called, and which will be responsible for making the
component behave as needed.
Caution
It is very important that if your file contains other
includes, they come before the include for SCA.php. If there are
includes after the include for SCA.php, they will not have been
processed when the SCA runtime runs your class.
The example below illustrates this overall structure
Example #1 The structure of an SCA for PHP component
<?php
// any includes
include "SCA/SCA.php";
/** * @service */
class ConvertedStockQuote {
// instance variables, business logic, including at least one public method