Service Component Architecture Samples

Setting up the samples

Extract the samples into the root of your Web server eg. C:\Program Files\Apache Group\Apache2\htdocs. All the samples are contained in the Samples directory, e.g. C:\Program Files\Apache Group\Apache2\htdocs\Samples.

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

All the samples are based around a simple "Hello" service. The hello services takes a string name and responds with the text "Hello <name>".

1. A script making a local call to an SCA Component

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

Run the sample: ScriptCallingLocalSCAComponent

2. A script making a remote (Web service) call to an SCA Component

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/Samples/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.ws annotation.

Run the sample: ScriptCallingRemoteSCAComponent

3. An SCA Component making a local call to another SCA Component

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

Run the sample: SCAComponentCallingLocalSCAComponent

4. An SCA Component making a remote (Web service) call to another SCA Component

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/Samples/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'.

Run the sample: SCAComponentCallingRemoteSCAComponent

5. A simple script making a remote (Web service) call to an SCA Component using data structures

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/Samples/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.

Run the sample: SCAComponentUsingDataStructures