IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Service Component Architecture programming > SCA programming model fundamentals

Client programming model

The SCA client programming model is designed to locate a service, to create data objects, to invoke a service, and to handle exceptions that are raised by the invoked component.

The SCA client programming model provides two primary functions for clients. The programming model exposes an interface that allows clients to locate services within the current module, and once a service is located the client programming model provides a way for the client to invoke operations on that service.

Clients locate services by using the ServiceManager class. There are a few ways to instantiate the ServiceManager class, depending on the wanted lookup scope for the service.

The key interface that clients should be aware of for locating services is com.ibm.websphere.sca.ServiceManager. This interface includes a locateService method that returns a reference to the service implementation for the service requested. The string parameter that is passed into the locateService method represents the reference name for the service that the client wants to locate. The Java™ documentation for the SCA programming model is included in the BPM information center, and is also included if you choose to install the Java documentation as part of the BPM installation.

Once a client has located the appropriate service, there are two types of invocation models that can be used to make a call to an operation or method offered by the service. First, there is a dynamic invocation style of interaction. The key interface for this style of interaction is com.ibm.websphere.sca.Service. The invoke() method on this interface takes the name of the operation that you are going to invoke, along with the parameters needed to call that operation.

public Interface MyService {
public String someMethod(String input);

Service myService = (Service) serviceManager.locateService(“myService”);
DataObject input = ...
DataObject result = (DataObject) myService.invoke(“someMethod”, input);

Clients can also use a static (type-safe) invocation method to call a particular operation associated with a service. This type of invocation only works for interface definitions that are specified as Java. In this situation, the client casts the return from the locateService() call to the appropriate interface and can proceed calling the appropriate type safe method calls on that interface.

public Interface MyService {
public String someMethod(String input);

MyService myService = (MyService) serviceManager.locateService(“myService”);
String input = ...
String result = myService.someMethod(input);

SCA programming model fundamentals