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".

Local Binding - 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 remote (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.

Soap Binding - An SCA Component making a remote (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'.

Soap Binding - A simple script making a remote (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.

First Steps With Soap, RestRpc and JsonRpc - HelloWorld

helloworld with PHP scripts Using only PHP scripts
helloworld with local SCA service binding An SCA Service accessed from a PHP script locally
helloworld with local SCA service and reference binding An SCA service access from another SCA service locally
Greeting Service WSDL Generation Generating WSDL
Reversing Service WSDL Generation Generating WSDL
helloworld with ws SCA service and binding Local binding replaced with a web services (SOAP) binding
helloworld with ws SCA service and reference binding Local binding replaced with a web services (SOAP) binding
helloworld with REST RPC SCA service binding and SDO message Complex types and REST binding
HelloWorld Service SMD Generation 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