Tuesday, April 27, 2010

Invoke Business Object Maps Using WebSphere Business Integration API

Use “com.ibm.wbiserver.map.MapService” interface to invoke Business Object Maps from your Java Classes.

Using the MapService interface is pretty straight forward.
  1. Use com.ibm.websphere.sca.ServiceManager class to lookup the MapService.
  2. Use appropriate methods on the MapService to invoke the Business Object Maps.
Let’s see a small example of how this is done. I have created a sample interface with one operation, an input BO (Business Object) (FromBO) and an Output BO (ToBO). I have also created a business object map to map from FromBO to ToBO. The picture below shows the details.

In the code sample below, the input to the operation is an instance of FromBO. We create an instance of ToBO and use the ‘simpleTranformation’ method on the MapService to invoke the ‘FromBO_ToBO_Map’ business object map.

public DataObject mapInputtoOutput(DataObject input1) {
               //create an instance of the output data object.
              BOFactory boFactory = (BOFactory)ServiceManager.INSTANCE.
              DataObject output1 = boFactory.create("http://SampleLib/com/test/bo", "ToBO");
              //locate the map service
             MapService serviceOne = (MapService)ServiceManager.INSTANCE.
             // invoke the business object map to do the transformation.
             try {
                                      "FromBO_ToBO_Map",input1, output1);
             } catch (WBIMapServiceException e) {
                      // TODO Auto-generated catch block
              } catch (WBIMapNotFoundException e) {
                     // TODO Auto-generated catch block
             } catch (WBIMapFailureException e) {
                   // TODO Auto-generated catch block
         return output1;

You can also use ‘transform’ method on the MapService interface if you would like to invoke business object maps that deal with transformations from multiple BOs to multiple BOs

Please check Must-Have bookmarks for IBM WebSphere Integration Developers for WAS API and other useful references.

No comments:

Post a Comment