Service Component Architecture Examples

Setup

Check that you have the SDO extension loaded - PHP Info

Extract the examples into the root of your Web server eg. C:\Program Files\Apache Group\Apache2\htdocs. All the examples are contained in the examples directory, e.g. C:\Program Files\Apache Group\Apache2\htdocs\examples. A number of samples are provided, which illustrate different aspects of the Service Component Architecture. For example, how to call SCA components from a PHP script or another SCA Component, how to expose SCA components as Web services, how to consume them as a Web service, and so on.

Local binding

A script making a local call to an SCA Component
ScriptCallingLocalSCAComponent
HelloClient.php - PHP script: This script gets a proxy to the local SCA component (HelloService.php), and calls its sayHello() method, passing in the name 'Bertie'.
HelloService.php - local SCA component: This component implements one method, sayHello($name), which takes in a name and returns the string "Hello $name".
An SCA Component making a local call to another SCA Component
SCAComponentCallingLocalSCAComponent
HelloClient.php - PHP script: This script gets a proxy to a local SCA Component (SurnameService.php), and calls its sayHello() method, passing in the name 'Bertie'.
SurnameService.php - local SCA component: This component implements one method sayHello($name) which takes in a name, adds the surname 'Beetle', and calls the sayHello() method on the local SCA component HelloService.php, passing in the new name.
HelloService.php - local SCA component: This component implements one method sayHello($name) which takes in a name and returns the string 'Hello $name'.

Soap Binding

A script making a SOAP web service call to an SCA Component
ScriptCallingRemoteSCAComponent
HelloClient.php - PHP script: This script calls a remote SCA Component (HelloService.php) to cause it to generate its WSDL definition. It then gets a proxy to the remote SCA Component and calls its sayHello() method, passing in the name 'Freddie'.
Note: The default location used for calling the service is http://localhost/examples/SCA/Soap/ScriptCallingRemoteSCAComponent/*.php. Please edit this location in HelloClient.php to point to the correct location in your environment if necessary, for example to add a port number.
HelloService.php - remote SCA component: This component implements one method, sayHello($name), which takes in a name and returns the string 'Hello $name'. It makes itself available as a Web service using the @binding.soap annotation.
An SCA Component making a SOAP web service call to another SCA Component
SCAComponentCallingRemoteSCAComponent
HelloClient.php - PHP script: This script gets a proxy to a local SCA Component (SurnameService.php), and calls its sayHello() method, passing in the name 'Freddie'.
Note: The default location used for calling the service is http://localhost/examples/SCA/Soap/SCAComponentCallingRemoteSCAComponent/*.php. Please edit this location in HelloClient.php to point to the correct location in your environment if necessary, for example to add a port number.
SurnameService.php - local SCA component: This component implements one method sayHello($name) which takes in a name, adds the surname 'Fish', and calls the sayHello() method on the remote SCA component HelloService.php, passing in the new name.
HelloService.php - remote SCA component: This component implements one method sayHello($name) which takes in a name and returns the string 'Hello $name'.
A simple script making a SOAP web service call to an SCA Component using data structures
SCAComponentUsingDataStructures
HelloClient.php - PHP script: This script gets a proxy to the local SCA Component (SurnameService.php), and calls its sayHello() method, passing in a list of names.
Note: The default location used for calling the service is http://localhost/examples/SCA/Soap/SCAComponentUsingDataStructures/*.php. Please edit this location in HelloClient.php to point to the correct location in your environment if necessary, for example to add a port number.
BatchService.php - remote SCA component: This component implement one method sayHello($names) which takes in a Service Data Object containing a number of names, and returns a new Service Data Object of the same format containing the string 'Hello $name' for each name.
names.xsd - data structure schema: This file is a simple XML Schema containing one complex type, called 'people'. This contains a many-valued element called 'name' for holding the names of people.

JSON-RPC Binding

A script making a variety of JSON calls to an SCA Component
MailApplicationClient

XML-RPC Binding

A script that uses the xmlrpc binding to drive another component
TestClient.php
Runs a script which calls a component locally, then the same component via the xmlrpc binding. The results should be the same, of course, but note the rounding errors in the floating point return.

REST resource-oriented Binding

A page that sends HTTP verbs to drive an SCA Component in the REST style
Orders
Drive two methods of the component yourself from the browser
Orders.php
Just following a link to Orders.php will send a GET and drive an enumerate and return XML
Orders.php/order2
Following a link to Orders.php/order2 will drive a GET for just orders2
The other methods require HTTP POST, PUT and DELETE and cannot be driven just by following links.
Rest resource binding
OrdersClient
A page that uses HTTP verbs to drive an SCA component as above, but that component drives another SCA component using the restresource binding. It will behave like the first example.

ATOM Publishing Binding

A page that calls a script that uses the atom binding to drive another component
test contact feed
Runs a script which drives create, retrieve, update and delete against an atom feed.
See the contents of the feed in the browser
Just fetch the contents and let the browser format it using the "xoxo" microformat.

First Steps With Soap, RestRpc and JsonRpc - HelloWorld

A PHP script calling classes helloworld.php is a PHP script which calls two local classes - no SCA at all
Using getService to get local proxies Helloworld is a PHP script which gets two local proxies to local components
A component with a rest-rpc binding calls local components helloworld.php is an SCA component with a rest-rpc binding. This gets two local proxies as above. The web page invokes helloworld with a POST.
Generate WSDL for the "Greeting" soap service Generating WSDL
Generate WSDL for the "Reversing" soap service Generating WSDL
Using getService to get soap proxies Helloworld is a script which gets two soap web service proxies
A component with a rest-rpc binding calls remote soap services Helloworld.php is an SCA component with a rest-rpc binding. This gets two soap web service proxies as above. The web page invokes helloworld with a POST.
As above but using SDO to pass data Complex types and REST binding
Generate an SMD Generating a JSON-RPC Service Method Description

Incremental Adoption - SCA Email

Generating EmailService WSDL Automatic WSDL generation
Email with ws SCA service binding PHP script locally accessing SCA Service
Email with ws SCA service and reference binding An SCA service accessing another SCA service
Generate ContactService SMD Automatic SMD Generation
Email with SDOs Complex types. Note this sample is written to work with DB2. Create a datable called email and apply contacts.sql before running