Composite business applications in WebSphere Business Services Fabric, Part 2: Modeling and implementing a composite business application

In Part 2 of this series, you'll learn how to enhance the model created in Part 1 in WebSphere® Business Modeler V6.2, and implement it in WebSphere Integration Developer V6.2 and WebSphere Business Services Fabric Composition Studio V6.2.

Share:

Diana Lau (dhmlau@ca.ibm.com), Software Developer, EMC

Diana Lau photoDiana Lau is a software engineer for the WebSphere Business Process Management SWAT team based in the IBM Toronto Software Lab. She works closely with customers resolving technical issues and providing best practices for implementing BPM solutions. You can reach Diana at dhmlau@ca.ibm.com.


developerWorks Contributing author
        level

Ying Sun (ysun@ca.ibm.com), Software Engineer, WSO2 Inc

Ying Sun is a software developer with the WebSphere Business Process Management SWAT team. He has over 10 years of experience working with a variety of products in the IBM software portfolio. He works closely with customers, helping them resolve technical issues and provide support for implementing BPM solutions. He can be reached at ysun@ca.ibm.com.



24 February 2010

Introduction

Using a customer relationship management (CRM) example, this article series shows you how to create a composite business application (CBA) in Business Space powered by WebSphere, enhance it in Business Modeler, and finally implement it in Integration Developer and WebSphere Business Services Fabric Composition Studio. In Part 1, you learned how a business user creates vocabulary, business concepts and other artifacts in Business Space. In Part 2, we'll cover modeling, which is typically performed by a business user who defines the content of the business variations, and the implementation aspect of CBA development, which is usually performed by an IT person.

Prerequisites

To build and run the scenario in this article, you must have the following products installed:

  • WebSphere Business Modeler V6.2 (hereafter called Modeler)
  • WebSphere Integration Developer V6.2 (hereafter called Integration Developer)
  • WebSphere Business Services Fabric Tool Pack V6.2
  • WebSphere Business Services Fabric V6.2 (hereafter called Fabric)
  • Lotus Forms Viewer 3.5.1

Prepare the environment

In this section, we'll set up the environment so you can use the artifacts created in Part 1 to continue the CBA development lifecycle.

If you have completed Part 1, follow these steps to import the vocabulary namespace into the CreateProfileApplication project.

  1. Open the Fabric administrative console (for example, http://myserver:9080/fabric).
  2. Select Governance Manager => Configure Projects.
  3. Switch to the Namespace tab.
  4. In the Imported Namespaces section, click Import Namespaces.
  5. Select Fabric Business Glossary as the project, and check CRMVocab.
  6. Click Import namespaces. The Imported Namespaces section should now have the five namespaces shown in Figure 1.
    Figure 1. Imported namespaces
    Imported namespaces

If Part 2 is your starting point, follow these steps to import the artifact to the Fabric server, or refer to Part 1 to create the artifacts from scratch.

  1. Open the Fabric administrative console (for example, http://myserver:9080/fabric).
  2. Select Governance Manager => Import / Export.
  3. Switch to the Import tab.
  4. Import the following 4 zip files (included in the Download section, in sequence:
    • FabricBusinessGlossary-owl.zip
    • CreateCustomerProfile-owl.zip
    • InformCustomer-owl.zip
    • CreateProfileApplication-owl.zip
  5. To verify that the import was successful, from the Fabric administrative console, select Governance Manager => Configure Projects. You should see the three added projects and additional items in the Fabric Business Glossary project.

In Part 1, we created a business space for the artifacts; however, you don't need to create this space for this part.


Author in Modeler

As described in Part 1, we created and governed the CBA example using Business Space. As a result, all artifacts we've created are stored in the Fabric repository. In order to refine the CBA at the business level, you'll need to import the artifacts into Modeler and add business level details for the service variations. Once the service variations have been defined, you can export the refined CBA model to Integration Developer and the Fabric Composition Studio for implementation at the technical level.

Import artifacts into Modeler

To import the artifacts into Modeler, do the following:

  1. Select File => Import => WebSphere Business Modeler => WebSphere Business Modeler Import, and click Next.
  2. Select WebSphere Business Services Fabric Repository elements.
  3. Click Add Repository, as shown in Figure 2.
    Figure 2. Select repository elements to import
    Select repository elements to import
  4. Enter the URL of the repository in the form of http://<server name>:<port number>, as shown in Figure 3. For example, http://myserver:9080. Use the same URL as the Fabric administrative console URL. Then click Finish.
    Figure 3. Specify repository location
    Specify repository location
  5. Under Repository content, check CRMAuthorSpace, as shown in Figure 4.
    Figure 4. Check CRMAuthorSpace
    Check CRMAuthorSpace
  6. Click Finish.

You've now created four projects in Modeler. You can see these in the Project Tree view, shown in Figure 5. The project structure is determined by the tool; it's considered a good practice to separate business objects from the business processes that use them.

Figure 5. New projects in the project tree
New projects in the project tree

Let’s examine the new projects. The CRMVocab project contains the business items, which correspond to the business concepts created in Business Space in Part 1.

The Create Customer Profile and Inform Customer projects correspond to the two business services created.

The Create Customer Profile project contains the business service Create Customer Profile, and two variations as empty processes, as shown in Figure 6. The Inform Customer project is similar.

Figure 6. Create Customer Profile project
Create Customer Profile project

The CreateProfileApplication project contains the main business process, shown in Figure 7.

Figure 7. CreateProfileApplication project
CreateProfileApplication project

Model the business variations

As mentioned earlier, the business variations (dealing with regular and preferred customers) are represented by processes in Modeler.

We're going to model the process for creating customer profiles for both regular and preferred customers. Modeler provides a comprehensive set of elements, such as human tasks and business rule tasks, that business users can use to construct a process. For simplicity, in this example we'll add human tasks to the business processes. In the Create Customer Profile project, the RegularCustomer_forCreate business process looks like Figure 8.

Figure 8. RegularCustomer_forCreate process
RegularCustomer_forCreate process

Figure 9 shows the PreferredCustomer_forCreate process.

Figure 9. PreferredCustomer_forCreate
PreferredCustomer_forCreate

Similarly, in the Inform Customer project, we'll add a human task to the InformRegularCustomerHT, InformPreferredCustomerHT for RegularCustomer_forInform, and PreferredCustomer_forInform processes, respectively, as shown in Figures 10 and 11.

Figure 10. RegularCustomer_forInform
RegularCustomer_forInform
Figure 11. PreferredCustomer_forInform
PreferredCustomer_forInform

Import the artifacts into Integration Developer

Next you need to export the artifacts from Modeler and import them into Integration Developer.

  1. Right-click CreateProfileApplication, then select WebSphere Integration Developer, as shown in Figure 12, and click Next.
    Figure 12. Export to Integration Developer
    Export to Integration Developer
  2. In the export details page, select Module + Library as the export option, as shown in Figure 13. The processes in the Modeler projects have only human tasks, therefore, you don't need to separate business logic from implementation details. However, it's always a good practice to separate the commonly used objects, such as business items and interfaces, from artifacts. This is why we're using this export option.
    Figure 13. Specify export details
    Specify export details
  3. You'll see the following warnings, which you can ignore. These warnings indicate that those processes contain Fabric artifacts that must be further implemented using the Fabric Toolpack.
    TEN20010W: The element "Inform Customer" uses the Dynamic Assembler
    implementation type, which is supported only in WebSphere Business
    Services Fabric.
    
    TEN20010W: The element "Create Customer Profile" uses the Dynamic Assembler
    implementation type, which is supported only in WebSphere Business
    Services Fabric.
  4. To import the files into Integration Developer, from Integration Developer and select File => Import => Other => Project Interchange, and click Next. You should see the projects in the project interchange file, as shown in Figure 14.
    Figure 14. Import project interchange into Integration Developer
    Import project interchange into Integration Developer

Author in Composition Studio

In this section, you'll learn how to map the higher level business services, which were created in Business Space in Part 1, to the actual services that are implemented in Integration Developer. The tasks include configuring the endpoints for different variations and creating context specifications, which specify the context necessary to make a dynamic assembly decision at runtime.

Create a Fabric project

First, create a Fabric project to pull in the vocabulary, business service, and other information from the Fabric repository. To do this, complete the following steps:

  1. Switch to the Business Service perspective
  2. Select Preferences => Business Service Fabric => Repository Configuration.
  3. Specify configuration details as shown in Figure 15, and click >Test Connection to make sure the repository connection is configured properly.
    Figure 15. Configure business services repository
    Configure business services repository
  4. Create a new Fabric project by selecting File => New => Project => Business Service Fabric => Fabric Project.
  5. Specify CreateCustomerProfileProject as the name of the project, and click Next.
  6. Select CreateProfileApplication as the Fabric project, as shown in Figure 16. This is the project created in Part 1. Then click Finish
    Figure 16. Create new Fabric project
    Create new Fabric project

You should see the following in the Business Service Explorer:

Figure 17. Business Service Explorer
Business Service Explorer

Create composite services

Create two composite services: Create Customer Profile and Inform Customer. A composite service is a unit of work accomplished by an interaction between components. Upon creation of the service, the interface and endpoints for calling this composite service are created.

In the Business Application explorer view, right-click Composite Service and select New => Composite Service. Specify the following information for both services:

Project Namespace SCA Project
CreateCustomerProfileProject CreateProfileApplication (Technical) CreateCustomerProfile
CreateCustomerProfileProject CreateProfileApplication (Technical) InformCustomer

You should see the following in the Business Service Explorer:

Figure 18. New composite services
New composite services

When creating the composite service, the Fabric Toolpack considers all exports of an SCA module as potential endpoints. However, only a subset of those exports are the true endpoints that you need. Therefore, you can safely delete both processes/createcustomerprofile/CreateCustomerProfile and processes/informcustomer/InformCustomer, as they're not required in this scenario

Configure the endpoints

Next, you need to configure the endpoints for the corresponding business variations. To configure the endpoint for processes/preferredcustomer_forcreate/PreferredCustomer_forCreate, do the following:

  1. In the Business Application Explorer, expand the Endpoint category and double-click processes/preferredcustomer_forcreate/PreferredCustomer_forCreate.
  2. In the endpoint editor, switch to the Assertion tab.
  3. Click Add and select Process Variation Assertion.
  4. Specify the values shown in Figure 19.
    Figure 19. Specify properties for process variation assertion
    Specify properties for process variation assertion
  5. Repeat these steps for each of the other endpoints.

Map composite services to the business services

Map the composite services (CreateCustomerProfile and InformCustomer) to the business services by completing the following steps:

  1. In the Business Application Explorer, double-click CreateCustomerProfile, as shown in Figure 20.
    Figure 20. Select CreateCustomerProfile
    Select CreateCustomerProfile
  2. Check Maps to a Business Application Module, as shown in Figure 21.
  3. For Business Application, select CreateProfileApplication.
  4. In the Business Service Mapping section, select Create Customer Profile for Business Service.
    Figure 21. Specify composite service details
    Specify composite service details
  5. In the Channel mapping section, selectEmail for PreferredCustomer_forCreate Export and RegularCustomer_forCreate Export, as shown in Figure 22. We're using email as the channel in this example.
    Figure 22. Select email as channel
    Select email as channel
  6. Repeat these steps for the InformCustomer composite service.

Create the context specification

Create two context specifications by doing the following:

  1. In the Business Application Explorer, right-click Context Specification and select New => Context Specification to create two context specifications with the properties shown in the following table.
    Project Name Namespace
    CreateCustomerProfileProject Create Customer Profile Context CreateProfileApplication (Technical)
    CreateCustomerProfileProject Inform Customer Context CreateProfileApplication (Technical)
  2. Since we'll determine whether a customer is preferred or regular based on the annual fee, you need to add a vocabulary dimension of Annual Fee for both context specifications. To do this, expand Context Specification in the project tree and double-click Create Customer Profile Context to open the context specification editor.
  3. Click Add and select Annual Fee, as shown in Figure 23.
    Figure 23. Requires a heading
    Requires a heading
  4. Repeat steps 2 and 3 for the Inform Customer Context context specification.

Publish the changes to the server

The final step in Composition Studio is to publish the changes to the server.

  1. Switch to the Repository Changes view, as shown in Figure 24.
    Figure 24. Switch to Repository Changes view
    Switch to Repository Changes view
  2. Right-click CreateCustomerProfileProject, and select Submit Change Set.
  3. Select Add All to submit all the changes, then click Finish.

Create context extractor in Integration Developer

Next you need to create a context extractor. A context is an object created for a service request in the business service model. The object contains information such as business process, organization, role and channel. The context extractor is needed so that the dynamic assembler component knows which context to look at when the service call arrives. Make sure the Business Integration perspective is open.

To create the context extractor, complete the following steps In the CreateCustomerProfile module:

  1. Right-click on WBSF server runtime library, and select Properties => Java Build Path.
  2. Select Server Runtime, as shown in Figure 25.
    Figure 25. Select library to add
    Select library to add
  3. Select WebSphere Business Services Fabric 6.2.
  4. Double-click CreateCustomerProfile to open the assembly editor.
  5. Right-click CreateCustomerProfile, then select Add => Reference.
  6. In the Add Reference dialog, select Show Java, then select the ContextExtractor interface from the com.ibm.websphere.fabric.da.plugin package.
  7. Create a Java™ component called CreateCustomerProfileContextExtractor and connect it with the CreateCustomerProfile component, as shown in Figure 26.
    Figure 26. Connect components
    Connect components
  8. Right-click CreateCustomerProfileContextExtractor to generate the implementation.
  9. In the Java editor, go to the extractContext(PendingRequest) method.
  10. Copy and paste the following code snippet into the method:
    	// extract annual fee from the request and put it into the context
    	final String ANNUAL_FEE = "fc://business/floatconcept#ue22c2689-6b47-40fb-bd22-c05eeb7d3ca5";   
    			
    	Context context = arg0.getContext();
    	DataObject body = arg0.getFirstBodyElement();
    	System.out.println(body);
    			
    	String annualFeePath = "//annualfee";
    	XPathSearchResult<String> annualFee = SdoXPathUtil.getViaXpath(body, annualFeePath);
    	if(annualFee != null){
    		context.setSelectionProperty(ANNUAL_FEE, new TypedValue(annualFee.getValue()));
    	}
    	return context;
  11. The value of annualFee is the URI of the AnnualFee concept. To look up this value, go to the Assertion Explorer expand the Business Vocabulary folder, and double-click AnnualFee, as shown in Figure 27.
    Figure 27. Open AnnualFee
    Open AnnualFee
  12. Click the copy URI icon next to the ID field, as shown in Figure 28, then paste the URI it to the Java editor. The URL should look something like this:
    	fc://business/floatconcept#ue22c2689-6b47-40fb-bd22-c05eeb7d3ca5
    Figure 28. Copy URI
    Copy URI
  13. Repeat these steps to implement the context extractor for InformCustomer, subsituting the following code snippet for the Java implementation:

    Click to see code listing

    final String IS_PREFERRED_CUSTOMER = "fc://business/booleanconcept#u94690d6a-36c4-44a8-81ae-4b375e32dce1";
    		
    Context context = arg0.getContext();
    DataObject body = arg0.getFirstBodyElement();
    System.out.println(body);
    
    String isPreferredCustomerPath = "//isPreferredCustomer";
    XPathSearchResult<String> isPreferredCustomer = SdoXPathUtil.getViaXpath(body, isPreferredCustomerPath);
    		
    if(isPreferredCustomer != null){
    	context.setSelectionProperty(IS_PREFERRED_CUSTOMER, new TypedValue(isPreferredCustomer.getValue()));
    }
    return context;

Test the service

Finally you need to test the service:

  1. Start the Fabric server and deploy all the modules to the server.
  2. Go to Business Space, and perform the following steps to invoke the CreateProfileApplication:
    1. Create a space called CreateProfileTestSpace with the template Managing Tasks and Workflow.
    2. Switch to the Create Tasks tab.
    3. In the Create Task widget, check CreateProfileApplication, then click Create, as shown in Figure 29.
      Figure 29. Create CreateProfileApplication task
      Create CreateProfileApplication task
    4. In the Task Information dialog, fill in the customer information, then click Submit, as shown in Figure 30.
      Figure 30. Specify customer information
      Specify customer information
  3. After the application is called, the human task for either the regular or preferred customer profile is created.
  4. Switch to the My Work tab and go to the Available Tasks dialog, as shown in Figure 31. Select CreateRegularCustomerProfileHT task.
  5. Since the annual fee is less than 100. it is going through the regular customer profile creation path; therefore, isPreferredCustomer is not checked.
    Figure 31. Accept the task
    Accept the task
    Figure 32. Output of the CreateRegularCustomerProfileHT
    Output of the CreateRegularCustomerProfileHT
  6. After the create profile task is completed, the inform customer task is called, as shown in Figure 33. Complete this task, and try another test with the annual fee greater than 100. This task should go through the preferred customer profile creation path.
    Figure 33. InformRegularCustomerHT is invoked
    InformRegularCustomerHT is invoked

You've seen that when the annual fee is less than 100, the CreateRegularCustomerProfileHT and InformRegularCustomerHT tasks are being invoked, and eventually the customer is not a preferred customer.  You can repeat the test in this session with the annual fee greater than 100, and the preferred customer path will be executed.


Acknowledgments

The authors would like to thank Jose De Freitas and Tom Al-Hamwy for their technical review of this article.


Conclusion

In this two-part series, we've walked through an end-to-end lifecycle of a composite business application using WebSphere business process management products. Using a simplified "create customer profile" scenario as an example, Part 2 showed you how to use WebSphere Business Modeler to enhance the business model, WebSphere Integration Developer to implement it, and WebSphere Business Services Fabric to configure a set of endpoints, each of which is invoked based on different context information carried by the current process instance.


Downloads

DescriptionNameSize
Project filesCreateCustomerProfile-owl.zip7KB
Project filesCreateProfileApplication-owl.zip7KB
Project filesFabricBusinessGlossary-owl.zip4KB
Project filesInformCustomer-owl.zip24KB

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=469182
ArticleTitle=Composite business applications in WebSphere Business Services Fabric, Part 2: Modeling and implementing a composite business application
publish-date=02242010