Client library for WebSphere Commerce services
The client library's simplifies and eliminate code on the client. The client library is a Java layer that helps Java applications integrate with your service architecture, without additional code generation. The client library already has support for session and authentication and provides Java-based clients a standardized mechanism to create the OAGIS SDO objects to represent service requests.
Each component provides a client library project to access the component. The client project contains the following items:
- Interfaces of the service provided for each noun
- A constant file that is sharable between client and server
- A client package that contains
- The abstract client Java class that contains common methods and methods required by the foundation framework
- A Web enabled Java class that extends from the abstract class to implement the Java friendly and Web enabled methods
- Noun specific exceptions to represent client errors and server errors
The subclass of the abstract client library class is a Web enablement client library class. The client provides finer grain methods to perform specific service actions. These fine grain methods build up the appropriate service request SDO and call the methods offered by the abstract client library class to perform the service request. The library only builds the service request object. It must not send the message or contain any additional business logic. The responsibility of sending is part of the abstract client library class and the additional business logic is the responsibility of the business task command using the client library.
An example of these Web enablement methods is seen in the following code:
// ============================================================================== // Programmer friendly APIs that can be used by clients to perform // more specific operations. These APIs are a convenient way to perform // common operations that clients of the SubsystemGroupName facade would perform. // ============================================================================== protected NounNameType buildNounName(java.util.Map parameters) { NounNameType nounName = SubsytemGroupNameFactory.eINSTANCE.createNounNameType(); String[] description = (String[]) parameters.get("description"); if (description != null) { nounName.setDescription(description[0]); } return nounName; } protected java.util.Map buildResponse(AcknowledgeNounNameDataAreaType dataArea) { java.util.Map result = new java.util.HashMap(); // populate response map ... return result; } public java.util.Map registerNounName(java.util.Map parameters) throws NounNameException { AcknowledgeNounNameType ack = super.processNounName(createProcessNounName("Register", buildNounName(parameters))); AcknowledgeNounNameDataAreaType dataArea = checkAcknowledgeNounName(ack.getDataArea()); return buildResponse(dataArea); }
Protocol authentication is used between the client and the server. This means that the transport contains identity information which will be converted into the WebSphere Commerce identity on the server. Although the business context information will be contained in the request document, the identity will not be part of the document. Security information is only carried in the SOAP header.
The basic authentication credentials will be found in the SOAP header or transport properties and WebSphere will resolve them to the appropriate identity.
- Client library authentication mechanisms
We can configure the binding of the transport mechanism we are using to provide the authentication credentials. The steps are dependent upon the transport we are using for Web services.- Web enablement for the client library
As a guideline of how to enable the client library for the Web, each action should be represented as a separate method. Ideally the Web client library has a corresponding method for each Web URL request for that component. For example in the case of a shopping cart, there are URL requests to add an item, update an item and remove an item. These three actions should be represented as different methods on the client library.
Related concepts
Client library authentication mechanisms
Service Data Objects (SDO)
Related tasks
Use a client library
Creating the client library
Deploying the client library
Related reference
Client library exceptions