This article introduces J2EE developers to the steps involved in building a simple solution to showcase integration between WebSphere Enterprise Service Bus V7 (hereafter called Service Bus) and WebSphere Service Registry and Repository V7 (hereafter called Service Registry). The development tooling of choice will be WebSphere Integration Developer V7 (hereafter called Integration Developer).
Service Registry is a central repository used to manage reusable service documents, including Web Services Description Language (WSDL), Service Component Definition Language (SCDL), Extensible Markup Language (XML), and XML Schema Definition (XSD) document types. The said service documents can be used as building blocks to develop composite applications that can be deployed on the Service Bus runtime.
The enterprise service bus of choice will be Service Bus, which is a runtime environment based on WebSphere Application Server (hereafter known as WAS). The mediation layer in Service Bus is used to execute mediation flows comprising of mediation primitives, which provides pre-built functionality to facilitate the rapid construction of integration solutions. One such mediation primitive is Endpoint Lookup, which we will be using to query the Service Registry from within a mediation flow.
The summary of steps we will take to complete this solution is to first create a backend service that resides on Service Bus, followed by defining the mediation flow that performs the lookup against Service Registry. This mediation flow will run on the same Service Bus runtime as the backend service. Lastly, we will create a Java API for XML Web Services (JAX-WS) JavaServer Page (JSP) based web service client to test the integration scenario.
Before proceeding with steps in this article, the following pre-requisites will have to be met:
- Integration Developer is installed on a Windows operating environment.
- Service Bus is installed with either a single server or clustered configuration and relevant servers started.
- Service Registry is installed (local to the Service Bus installation) with either a single server or clustered configuration and relevant servers started.
- Service Registry definition configured and connection established successfully.
- IBM HTTP Server V7 (hereafter known as IHS) is installed (local to the Service Bus installation) and configured.
We will start off by creating a sample backend service that is represented by a Java implementation. The said service will return the application server name on which the service is executed. The application server profile used in this scenario will be that of the Service Bus.
- Launch Integration Developer by selecting Start > All Programs > IBM WebSphere Integration Developer > IBM WebSphere Integration Developer V7.0 > WebSphere Integration Developer V7.0.
- In the Integration Developer workspace, click File > New > Integration Solution.
- In the dialog shown in Figure 1, type
IntegrationSolutionin the Integration solution name field and click Next.
Figure 1. New Integration Solution dialog
- In the next dialog, select all three projects with the default names as depicted in Figure 2 and click Finish to complete the wizard.
Figure 2. Add projects dialog
- Verify that the three projects appear in the list as depicted in Figure 3.
Figure 3. Projects listed in Business Integration view
- Expand IntegrationSolution_Library in the Business Integration view, right-click on Interfaces and select New > Interface from the context menu.
Figure 4. Launch interface wizard
- Type
ServiceInterfacein the name field and click Finish to complete the wizard.
Figure 5. Create an Interface dialog
- The interface is launched in the Interface Editor as shown in Figure 6.
Figure 6. Interface Editor
- Click the Add Request Response Operation icon and name the operation
getServerResponseas shown in Figure 7.
Figure 7. Add Request Response Operation
- Click File > Save to save changes made thus far.
- Expand IntegrationSolution_BackendModule (under Projects in the Business Integration view) and double-click on Assembly Diagram to launch the Assembly Editor.
Figure 8. Assembly Diagram of IntegrationSolution_BackendModule
- Insert a Java component (under the Components folder in the Palette list) onto the
blank canvas and name it
BackendComponent.
Figure 9. Java component
- Select BackendComponent and click the Add Interface icon in the popup as shown in Figure 10.
Figure 10. Add Interface
- In the Add Interface dialog, select ServiceInterface and click OK.
Figure 11. Select ServiceInterface
- Verify the interface is added successfully.
Figure 12. Verify Interface
- Right-click on BackendComponent and select Generate Implementation from the context menu.
- When prompted for a package name, key in com.ibm.au.samples and click OK.
- The BackendComponentImpl1.java class will be displayed in the Java Editor as shown in Figure 13.
Figure 13. BackendComponentImpl1.java
- Replace the
getServerResponsemethod body with the code snippet shown in Figure 14.
Figure 14. getServerResponse method
- Click File > Save All to save changes made thus far.
- Switch to the IntegrationSolution_BackendModule Assembly Diagram.
- Right-click on BackendComponent and select Generate Export > Web Service Binding from the context menu.
- Select the SOAP1.1/HTTP transport protocol and click Finish to complete the wizard.
Figure 15. Select transport protocol
- Verify that the Web Service Binding Export is generated successfully.
Figure 16. Web Service Binding Export for BackendComponent
- Expand IntegrationSolution_Library > Web Service Ports (under Projects in the Business Integration view) and double-click on ServiceInterfaceExport1_ServiceInterfaceHttpPort to launch the said file in the WSDL Editor.
- Select ServiceInterfaceExport1_ServiceInterfaceHttpPort and type
http://<hostname>:<port>/ IntegrationSolution_BackendModuleWeb/sca/ServiceInterfaceExport1in the Address field. (The <hostname> refers to the fully qualified domain name of the machine on which Service Bus is installed and <port> refers to the value found at Servers > Server Types > WebSphere application servers > [Service Bus application server] > Ports > WC_defaulthost of the Integrated Solutions Console, where [Service Bus application server] represents the default application server of the Service Bus profile.)
Figure 17. Change port address of BackendModule export
- Click File > Save All to save changes made thus far.
- Click File > Export to launch the export wizard.
- In the dialog shown, select Integration modules and libraries under the Business Integration folder and click Next to proceed.
Figure 18. Export Integration modules and libraries
- In the subsequent dialog, select Files for server deployment, the IntegrationSolution_BackendModule project and click Next to proceed.
Figure 19. Select Project
- Type in an archive file name e.g.
IntegrationSolution_BackendModule.ear,specify a Target directory to export the project to and click Finish to complete the wizard.
Figure 20. Specify archive file name
- To export the WSDL files which are to be uploaded to Service Registry, click File > Export.
- In the subsequent dialog, select WSDL and XSD under the Business Integration folder and click Next to proceed.
Figure 21. Export WSDL and XSD
- In the dialog as shown in Figure 22, complete the following.
- Select the IntegrationSolution_Library project.
- Select the IntegrationSolution_BackendModule_ServiceInterfaceExport1.wsdl and ServiceInterface.wsdl WSDL files.
- Specify a Target directory to export the WSDL files to.
- Click Finish.
Figure 22. Select WSDL files
Upload the service to Service Registry
In this section, we will showcase steps to upload the newly created service to Service Registry. We will then proceed to add properties to the said service and perform a query of the service using the properties as part of the query string.
- Log on to the Service Registry console at
http://<hostname>:<port>/ServiceRegistry. (The <hostname> refers to the fully qualified domain name of the machine on which Service Registry is installed and <port> refers to the value found at Servers > Server Types > WebSphere application servers > [Service Registry application server] > Ports > WC_defaulthost of the Integrated Solutions Console, where [Service Registry application server] represents the default application server of the Service Registry profile.) - Click Actions > Load Documents
Figure 23. Load service document
- Select IntegrationSolution_BackendModule_ServiceInterfaceExport1.wsdl from
the local file system and complete the following:
- Select WSDL as the Document type.
- Type
ServiceBackendas the document description. - Type 1.0 as the document version.
- Click OK.
Figure 24. Select backend service WSDL
- In the next screen, click Add.
Figure 25. Add service interface
- Select ServiceInterface.wsdl from the local file system and complete the
following:
- Select WSDL as the Document type.
- Type
ServiceInterfaceas the document description. - Type 1.0 as the document version.
- Click OK.
Figure 26. Select service interface WSDL
- In the next screen, click Finish to complete the wizard.
Figure 27. Load service documents
- Verify that the service documents are loaded successfully.
Figure 28. Upload of service documents complete
- In the search field as depicted in Figure 29, type
ServiceInterfaceExport1_ServiceInterfaceHttpPortand click on the search icon.
Figure 29. Search documents
- Click on the ServiceInterfaceExport1_ServiceInterfaceHttpPort link of object type Port.
Figure 30. Query results
- Expand the Additional Properties section and click on Edit Properties.
Figure 31. Edit document properties
- Click on Add Property.
Figure 32. Add Property
- Type
samplePropertyin the Custom Property Name field and click Add.
Figure 33. Add custom property name
- Type
abc123defin the value field of the custom property and click OK.
Figure 34. Add custom property value
- Expand the Additional Properties section to verify that the custom property has been added successfully.
Figure 35. Verify custom property
- Click Actions > Query Wizard.
Figure 36. Launch query wizard
- Select WSDL Ports from the entity type drop down list and click Next.
Figure 37. Select entity type
- In the details page of the query wizard, specify the values below and click
Next to proceed.
- Type
samplePropertyin the Property name field. - Type
abc123defin the Property value field
- Type
Figure 38. Enter property name and value
- At the summary page of the query wizard, click Finish to perform the query.
Figure 39. Search summary
- Click on the ServiceInterfaceExport1_ServiceInterfaceHttpPort link.
Figure 40. Query results
- Verify the custom property sampleProperty exists.
Figure 41. Additional Properties
In this section, we will discuss steps to define a mediation flow that will encompass the use of the Endpoint Lookup and Trace mediation primitives. The former mediation primitive will perform a lookup against the default service registry (which should already be defined in Service Bus and connection established successfully). The latter mediation primitives are to facilitate troubleshooting in the event of a failure.
- From within Integration Developer, double-click Assembly Diagram under the
IntegrationSolution_MediationModule project to launch the Assembly
Editor and name the Mediation Flow component
SampleMediation. (Note that a default Mediation Flow component exists upon creating the Mediation Module.)
Figure 42. Mediation Module
- Select SampleMediation and click the Add Interface icon in the popup as shown in Figure 43.
Figure 43. Add Interface
- In the Add Interface dialog, select ServiceInterface and click OK.
- Select SampleMediation and click the Add Reference icon in the popup as shown in Figure 44.
Figure 44. Add Reference
- In the Add Reference dialog, select ServiceInterface and click OK.
- Right-click on SampleMediation and select Generate Implementation from the context menu.
- In the Generate Implementation dialog, select the IntegrationSolution_MediationModule folder and click OK.
- The SampleMediation component will be launched in the Mediation Flow Editor as shown in Figure 45.
Figure 45. Mediation Flow Editor
- Click on the getServerResponse link in the Mediation Flow Editor followed by the Service Integration link in the pop up as shown in Figure 46.
Figure 46. Create mediation flow
- In the Integrate Services dialog, click Add to select the ServiceInterfacePartner reference, leave the option to Create a separate response flow... checked and click OK to create the mediation flow.
Figure 47. Create mediation flow
- Verify that both the Request and Response tabs are shown in the Mediation Flow Editor.
Figure 48. Request and response flows generated
- Add 3 Trace mediation primitives (under the Tracing folder in the
Palette) to the
Request flow and name them
BeforeLookup,AfterLookupandNoMatchFound, as shown in Figure 49.
Figure 49. Add Trace mediation primitives to Request flow
- Add an Endpoint Lookup mediation primitive (under the Routing folder in the
Palette) and name it
WSRREndpointLookup.
Figure 50. Add Endpoint Lookup mediation primitive to Request flow
- Connect all mediation primitives in the Request flow as shown in Figure 51.
Figure 51. Connect terminals in Request flow
- Click on the Response tab in the Mediation Flow Editor, add a Trace mediation primitive and name it TraceResponse, as shown in Figure 52.
Figure 52. Add Trace mediation primitive to Response flow
- Connect all mediation primitives in the Response flow as shown in Figure 53.
Figure 53. Connect terminals in Response flow
- Switch back to the Request flow (by clicking on the Request tab in the Mediation
Flow Editor), select BeforeLookup and add in the prefix
BeforeLookup ---in the Message field (under the Details section of the Properties view).
Figure 54. Details of BeforeLookup
- Repeat step 17 for AfterLookup as shown in Figure 55.
Figure 55. Details of AfterLookup
- Select NoMatchFound and update the following fields under the
Details section of
the Properties view.
- Select File in the Destination drop down list.
- Specify an absolute File path e.g.
C:\temp\dWSampleNoMatchFound.log - Add in the prefix
NoMatchFound ---in the Message field.
Figure 56. Details of NoMatchFound
- Select WSRREndpointLookup and verify the fields under the Details section of the Properties view are as shown in Figure 57.
Figure 57. Details of WSRREndpointLookup
- Select WSRREndpointLookup, click Advanced in the Properties view and click Add.
Figure 58. Advanced properties of WSRREndpointLookup
- In the Add/Edit properties dialog as shown in Figure 59, type
samplePropertyin the Name field,/body/getServerResponse/input1in the Value field and click Finish.
Figure 59. Add user property
- Verify that the user property added in step 22 is listed in the Advanced section of the Properties view.
Figure 60. Verify user property added
- Double-click Assembly Diagram under the IntegrationSolution_MediationModule project in the Business Integration view to launch the Assembly Editor.
- Right-click SampleMediation in the Assembly Editor and select Generate Export > Web Service Binding from the context menu.
- In the Select a Transport Protocol dialog, select SOAP1.1/HTTP and click Finish to generate the export.
- Verify the Web Service Binding Export is generated successfully.
Figure 61. Web Service Binding Export for SampleMediation
- Double-click the ServiceInterfaceExport1_ServiceInterfaceHttpPort web service port under the IntegrationSolution_Library project in the Business Integration view as shown in Figure 62.
- Select ServiceInterfaceExport1_ServiceInterfaceHttpPort in the WSDL Editor and type
http://<hostname>:<port>/IntegrationSolution_MediationModuleWeb/sca/ServiceInterfaceExport1in the Address field. (The <hostname> refers to the fully qualified domain name of the machine on which Service Bus is installed and <port> refers to the value found at Servers > Server Types > WebSphere application servers > [Service Bus application server] > Ports > WC_defaulthost of the Integrated Solutions Console, where [Service Bus application server] represents the default application server of the Service Bus profile.)
Figure 62. Change port address of SampleMediation export
- Click File > Save All to save changes made thus far.
- To export the deployable artifacts for this project, click File > Export.
- In the subsequent dialog, select Files for server deployment, the IntegrationSolution_MediationModule project and click Next to proceed.
- In the final dialog of the Export wizard, specify an Archive File Name e.g.
IntegrationSolution_MediationModule.ear, select a Target directory to export the project to and click Finish to complete the export.
In the following section, we will cover steps to create a web application comprising of JSPs and classes generated by the JAX-WS web service client wizard. JAX-WS is a web services programming model that builds on the foundation of the Java API for XML-based RPC (JAX-RPC) model and provides a more platform agnostic approach to defining web service clients. The web application will be used to verify integration between Service Bus and Service Registry by invoking the web service binding export of the SampleMediation mediation flow.
- In the Integration Developer workspace, click File > New > Other.
- In the dialog shown in Figure 63, select Enterprise Application Project under the Java EE folder and click Next to proceed.
Figure 63. Create an enterprise application project
- In the next dialog, type
SampleClientin the Project name field, leave the rest as default and click Next to proceed.
Figure 64. Properties of the enterprise application project
- Next, click New Module.
Figure 65. Define a dependent module
- In the subsequent dialog, select Web module, leave the value as default and click Finish.
Figure 66. Create the web module
- Lastly, verify SampleClientWeb is selected and click Finish to complete the wizard.
Figure 67. Verify web module added
- When prompted to switch to the Java EE perspective, click No.
- Next, click File > New > Other and select Web Service Client under the Web Services folder.
- In the subsequent dialog, type
/IntegrationSolution_Library/IntegrationSolution_MediationModule_ServiceInterfaceExport1.wsdlin the Service definition field and click on the Server:... link.
Figure 68. Select service definition
- Next, select WebSphere ESB Server v7.0 as the Server, IBM WebSphere JAX-WS as the Web service runtime and click OK.
Figure 69. Select web service runtime
- Next, click on the Client project:... link.
Figure 70. Specify client project
- In the subsequent dialog, select SampleClientWeb as the client project and click OK.
- Verify that the Configuration is as shown in Figure 71 and click Next to proceed.
Figure 71. Verify configuration
- In the final dialog of the wizard, check Generate portable client, leave the rest as default and click Finish. (When the Generate portable client option is checked, a local copy of the WSDL files are stored in the <WebModule>/WebContent/WEB-INF/wsdl folder.)
Figure 72. Complete configuration of web service client
- Switch to the Java EE perspective by clicking Window > Open Perspective > Other > Java EE.
- Verify that the Java classes as shown in Figure 73 are listed in the Enterprise Explorer view.
Figure 73. Java classes in Enterprise Explorer view
- Verify that a Service Bus server configuration exists within the Integration Developer workspace.
Figure 74. Server configuration
- Right-click on ServiceInterfaceExport1_ServiceInterfaceHttpPortProxy.java under SampleClientWeb > Java Resources > integrationsolution_library.serviceinterface.binding2 and select Web Services > Generate JAX-WS JSPs from the context menu.
- In the Web Service Client Test dialog, check Test the generated proxy, type
formin the Folder field, uncheck Run test on Server, leave the rest as default and click Finish to complete the wizard.
Figure 75. Web service client configuration
- Verify JSPs as shown in Figure 76 are listed in the Enterprise Explorer view.
Figure 76. JAX-WS JSPs
- To export the deployable artifacts for this project, click File > Export.
- In the subsequent dialog, select EAR file under the Java EE folder and click Next to proceed.
- Next, select SampleClient as the EAR project, specify a Destination to export the project to, leave the rest as default and click Finish to complete the export.
Deploying the applications to Service Bus
Next, we will deploy the exported integration modules and web project to the Service Bus runtime via the Integrated Solutions Console. Web modules of all applications will be mapped to both the Service Bus application server and IHS.
- Log on to the Integrated Solutions Console at
http://<hostname>:<port>/ibm/console. (The <hostname> refers to the fully qualified domain name of the machine on which Service Bus is installed and <port> refers to the default value of 9060.) - Navigate to Applications > New Application > New Enterprise Application.
- Select the IntegrationSolution_BackendModule.ear file from the Local file system and click Next.
- Select Fast Path and click Next.
- In the subsequent screen, leave the values as default and click Next.
- Next, map IntegrationSolution_BackendModuleWeb to the Service Bus application server and web server in the Cluster and servers list, then click Next to proceed.
Figure 77. Map modules to servers
- Review the summary of the deployment and click Finish to install the application.
- Click Review after the installation completes.
- Select Synchronize changes with Nodes and click Save.
- When the synchronization is complete, click OK.
- Navigate to Applications > Application Types > WebSphere enterprise applications, select IntegrationSolution_BackendModuleApp and click Start.
- Repeat steps 1 – 11 to install and start the following applications.
- IntegrationSolution_MediationModule.ear
- SampleClient.ear
In this final section, we will access the SampleClientWeb web application via a browser. The said application receives an input string from the web form and either returns the Service Bus application server name on which the backend service is executed or a null value if no match is found in Service Registry. Upon executing the said test, we will review the SystemOut.log file of the Service Bus application server to verify that messages have been logged by the Trace mediation primitives.
- Launch the web application in a browser by accessing
http://<hostname>/SampleClientWeb/form/TestClient.jsp(The <hostname> refers to the fully qualified domain name of the machine on which IHS is installed. We do not explicitly specify a port as the web module of the enterprise application is mapped to IHS.)
Figure 78. SampleClientWeb
- Click on the getServerResponse link in the Methods frame, type 10 (or any alphanumeric
string value other than
'abc123def') in the input1 field and click Invoke. - Verify that 'null' is displayed in the Results frame as shown in Figure 79.
Figure 79. No match found
- Open C:\temp\dWSampleNoMatchFound.log in a text editor and view message logged by Trace mediation primitive.
Figure 80. dWSampleNoMatchFound.log
- Next, type
abc123defin the input1 field and click Invoke. - Verify that 'Server response from <Service Bus application server> with input abc123def' is displayed in the Results frame as shown in Figure 81. (The <Service Bus application server> refers to the default application server of the Service Bus profile.)
Figure 81. Response from server
- Switch back to the Integrated Solutions Console and navigate to Troubleshooting > Logs and trace > [Service Bus application server] > JVM Logs. (The [Service Bus application server] is the default application server of the Service Bus profile.)
- Click on the Runtime tab and click View next to SystemOut.log.
- View messages logged by Trace mediation primitives as shown in Figure 82.
Figure 82. SystemOut.log
In this article, you learned how to develop a solution using Integration Developer that showcases integration between Service Bus and Service Registry. You started off by creating a sample backend service and then uploaded the said service to Service Registry. You then defined a mediation flow that performs the lookup against Service Registry and generated a JAX-WS web service client to test the integration scenario.
I would like to thank my team mate, Damien McAullay at the Australia Development Laboratory WebSphere Services team for reviewing this article.
- Find more details on Service Registry in
the WebSphere Service Registry and Repository V7 Information Center.
- Find more details on Services Details in
the WebSphere Enterprise Service Bus V7 Information Center.
- Learn how to implement WebSphere Business Process Management V7 topologies by referring to the WebSphere Business Process Management V7 Production Toplogies Redbook.
- Read details about Java API for XML Web Services.





