Dynamic Endpoint Lookup on TIBCO BusinessWorks with WSRR
Dynamic endpoint lookup has become a useful feature for decoupling services. Mediation patterns like Dynamic Service Gateway use this feature, thus Service Consumers don’t actually know which service is attending their request.
IBM's products are well integrated to offer this feature; Websphere Enterprise Service Bus (WESB) and Websphere Message Broker (WMB) communicate natively with Websphere Service Registry and Repository (WSRR) for querying services and allow dynamic endpoint routing.
The following diagram depicts how this pattern works:
Figure 1. Dynamic Endpoint Lookup
When a third party tool comes into play, in this case TIBCO BusinessWorks, this pattern can be implemented leveraging open standards (as SOAP):
Figure 2. TIBCO Dynamic Endpoint Lookup
A TIBCO BusinessWorks process listening to an EMS queue can be implemented to be reusable across all mediation services.
Figure 3. Architecture Overview
This article covers all the required steps to implement Dynamic Endpoint Lookup on TIBCO BusinessWorks with Websphere Service Registry and Repository.
1.1 Service Metadata Structure and Xpath expression to acquire Service endpoint SOAP address
This document covers the simple metadata structure generated when importing a WSDL Document into WSRR (more complex taxonomies and Xpath expressions can be exploited and generated as described in the WESB Endpoint lookup with WSRR and the GEP article).
Uploading service definitions is explained in Service Lifecycle Governance with IBM WebSphere Service Registry and Repository V6.3, SG24-7793 redbook and will not be described in this article.
When importing WSDL documents into WSRR, Service Metadata is structured as follows:
Figure 4. Service Metadata Structure
Xpath allow us to navigate through this structure from the Service item to the PortType item:
With this expression, SOAP Address item can be acquired with PortType properties, i.e. name, namespace and/or other properties.
/WSDLService/ports[binding(.)/portType(.)[@name = '%1' and @namespace='%2']]
1.2 Named Queries
Named Queries are Xpath expressions identified by a name and stored in WSRR. Use of Named Queries is one of the best options to search information from WSRR in terms of performance (due the xpath query expression pre-compilation). Also, they can be uploaded from WSRR web console.
Named Query Example:
Figure 5. Named Query
1.3 Registering Named Query via WSRR Console
Log in as Administrator in WSRR web console (default in a local machine is https://localhost:9445/ServiceRegistry/).
Select the Configuration perspective.
Figure 6. Configuration Perspective
From the Active Profile menu, select Named Queries option.
Figure 7. Named Queries Profile
Press Load Named Query Configuration button.
Figure 8. Load Named Query
Locate Named Query Configuration XML file, and enter a name for this configuration:
Figure 9. Named Query Name and Location
Finally, press OK.
Now the Named Query is ready for execution.
2.1 Download WSRR SSL Certificates
Certificates can be downloaded with OpenSSL tool(http://www.openssl.org/). From a cmd window, run the following command:
openSSL s_client –connect host:port –showcerts
Host: Host name or IP address where WSRR is installed
Port: Port number where WSRR is installed
Copy all the command execution result, and paste it in a text editor.
Save the new file with .pem extension.
The beginning of the certificate should resemble the following lines:
Figure 10. Certificate Chain
The ending lines of certificate chain looks like the following image :
Figure 11. Certificate Chain End
2.2 Import SSL Certificates with TIBCO Designer
Create the destination folder where the certificates will be imported.
Figure 12. Create Folder
Select the destination folder in the current TIBCO Designer project, select Tools, Trusted Certificates, and finally Import Into PEM Format:
Figure 13. Import Certificates
Press Search button and locate the .pem file that you just generated in the step 2.1
Figure 14. Import Certificate Window
Once selected, press OK.
Figure 15. Certificate Location
TIBCO Designer will create the certificates in the selected folder.
Figure 16. Imported Certificates
2.3 Identity Configuration
WSRRCoreSDOPort WEB service requires realm authentication, hence a username and a password must be provided through an identity in the SOAP Request-Reply HTTP Basic Authentication config.
Right click the selected folder, then Add Resource, then General and finally Identity.
Figure 17. Identity Creation
Enter a name for the new Identity configuration, select Username/Password type, and the user and the password to connect to WSRR (Default username is "admin" and Password is "admin"). Finally press Apply.
Figure 18. Identity Configuration
2.4 WSRR Global Variables Settings
Global variables allow us to define a set of variables that can be modified on the TIBCO Admin console without redeploying or code modification.
Select Global Variables from the left panel and press Open Advanced Editor button.
Figure 19. Global Variable Creation
Press Add a Variable Group button and name it as WSRR.
Figure 20. Global Variable Creation, step 2
Select the new Variable Group, and press Add Variable, name it as Host. Add two more variables, one for the WSRR Port and another for the Named Query name and assign their corresponding values.
Figure 21. Global Variable Creation, step3
Finally press the OK button.
2.5 Process Input-Output Schema
In order to receive and return information from the process, we will use a xsd schema (TIBCODynamicLookup.xsd) with the following structure:
Figure 22. Input Element
Figure 23. Output Element
2.6 Dynamic Endpoint Lookup Process Design
Now that we have the proper Identity Configuration, SSL certificates, WSRRCoreSDOPort service WSDL document (available at https:// WSRR_Host: WSRR_Port/WSRRCoreSDO/services/WSRRCoreSDOPort?wsdl) and required schemas (datagraph.xsd, Options.xsd, WSRRSDO.xsd and wsrrSdoWs.xsd), we will design a reusable Business Works process to interact with WSRR.
NOTE: Since TIBCO BusinessWorks has validation issues with XML ID type values returned from WSRR, you must change all xs:id, xs:idref and xs:idrefs types from WSRRSDO.xsd to xs:string (the provided xsd file is already modificated modified).
The process will be implemented according to the following diagram:
Figure 24. Process design
Create a new process by right clicking the target folder, select Add Resource, then Process, and finally Process Definition. Enter a name for the new process (for example, WSRR Dynamic Lookup).
Figure 25. TIBCO Process
Select the new process. On design panel, add the following components:
- SOAP Request-Reply Node
Figure 26. SOAP RequestReply
- Catch Node
Figure 27. SOAP Catch
Some other nodes might be added, i.e., a component to write to a log or another process to report a problem (if available) when an exception is catch.
Connect the components as depicted in the following image:
Figure 28. Dynamic Lookup Process
Select Start node, and on the configuration panel, select Output Editor tab. Add a new child by pressing the Add child button:
Figure 29. Start Output Editor
Select XML Element Reference from the Content list. Press Browse resources...
Figure 30. Start Output Content type
Locate the TIBCODynamicLookup.xsd schema and select the params element.
Figure 31. Start Output Element
Press Apply button.
Now select the SOAP Request Reply node. In the configuration panel, enter a name for the node, for example WSRR Lookup, and press the Browse resources button.
Figure 32. WSRR SOAP Request Reply Configuration
Locate and select the WSRRCoreSDOPort service WSDL document.
From the Operation list select executeNamedQueryWithParameters.
Figure 33. WSRR Service Operation
Select the Transport Details panel. On the Endpoint URL value, replace the IP address and Port number from the URL with the Global Variables values defined on prior sections.
Figure 34. WSRR Host and Port Global Variables
Select Basic Authentication checkbox, press the Browse resources... button; locate and select the WSRR Identity Configuration created on previous sections.
Figure 35. WSRR Basic authentication
Press Configure SSL... button. On the SSL Configuration for HTTPS Client Requests windows, press Browse resources... button; locate and select the folder where SSL certificates were imported.
Figure 36. WSRR SSL Configuration
Finally press the OK button.
Figure 37. SSL Certificates Location
Select the Input panel. Assign QueryName Global Variable to query parameter, and for each param, assign one parameters.
Figure 38. WSRR Operation Parameters
Choose the first option to define Xpath expression and click finish button.
Figure 39. Parameters Mapping
Now, from the process graph, select the End node. On the configuration panel, select Input Editor tab and press the Add child button.
Figure 40. End Input Editor
Select XML Element Reference from the content list, then press Browse resources... button, locate the TIBCODynamicLookup.xsd file and select the result element.
Figure 41. End Input Element
Press the Apply button.
Select the Input tab.
Operation executeNamedQueryWithParameters returns a list of Base Objects (super class from which some models or classes inherits). In order to select the desired Base Object, results must be casted into a WSDLService Type. Select the artifacts element from response schema, and press the Coercions button.
Figure 42. WSRR Result Coercion
Press the Insert button and locate the WSRRSDO schema.
Figure 43. WSRR XML Type Reference and schema location
Select the WSDLService type and press OK.
Figure 44. WSRR WSDL Service Type
Close the Coercions window by pressing OK.
Navigate through the structure of elements to find the element "location", drag and drop it to the Xpath formula section, this action will generate an XPath expression.
Figure 45. Mapping Location Attribute
After that, you must add some filters to the generated Xpath expression to assign the value to the response by filtering and navigating through the WSRR results:
- ns2:datagraph is the first result in the array.
- pfx2:artefacts[@xsi:type = 'sdo_1:WSDLService'] filters the elements to get only those which are WSDLService objects
- pfx2:ports is the first port returned for the desired Service.
The resulting Xpath expression must look like this:
Listing 1. Listing 1. Xpath expression to filter results
$WSRR-Lookup/outputMessage/pfx:executeNamedQueryWithParametersResponse/results/ ns2:datagraph/pfx2:WSRR/pfx2:artefacts[@xsi:type = 'sdo_1:WSDLService']/ pfx2:ports/pfx2:SOAPAddress/@location
Notice that this expression returns the first result, no matter how many there are. There are no business rules to select an endpoint. This kind of functionality (endpoint selection) is provided by IBM offerings as WebSphere Business Services Fabric.
2.7 Decoupling the process from the transport
To avoid transport coupling (in this case, JMS), we will design another process to listen to a JMS queue, invoke WSRR Dynamic Lookup process, and reply to the invoker.
Figure 46. JMS Dynamic Lookup Receiver Design
- Parse XML parses the message body from the queue and returns the corresponding schema, in this case, params element.
- WSRR Dynamic Lookup invokes the process
- Reply to JMS Message replies the result to the invoker.
2.8 Enabling Dynamic Routing with SOAP Request-Reply node
Now, in the mediation process, we can send a message with the correct parameters to the corresponding JMS queue and wait for the reply.
Consider the following simple service mediation process:
Figure 47. Mediation Process Design
- LookupParams creates an xml element with the corresponding parameters for the named query execution.
- Endpoint Lookup writes the message to the queue and waits for the reply.
- ParseWSRRResponse parses the response body message.
- Log writes the WSRR response.
- ABC Service invokes the service.
Dynamic routing is enabled by assigning the result value from the Dynamic Lookup process to the endpointURL element in the SOAP Request-Reply component to invoke an external service, so the component overrides the configured endpoint.
Figure 48. SOAP Request Reply Endpoint Overriding
This article shows how IBM products support and promotes open standards to allow interaction with other technologies. In this scenario, TIBCO BusinessWorks leverages WSRR capabilities to dynamically route a service invocation based on basic contract service information (portType name, namespace) in runtime by applying a Service Dynamic Gateway mediation pattern.
- "WebSphere ESB endpoint selection based on the WebSphere Service Registry and Repository Governance Enablement Profile" (developerWorks, Aug 2010) is an article about WSRR Governance Enablement Profile based endpoint selection.
- Read on the WebSphere Service Registry and Repository product page product descriptions, product news, training information, support information, and more.
- WebSphere Service Registry and Repository information center is a single Web portal to all WebSphere Service Registry and Repository documentation, with conceptual, task, and reference information to help you install, configure, and use the product.
- Read further in the WebSphere ESB documentation library.
- The WebSphere ESB information center is a single Web portal to all WebSphere ESB documentation, with conceptual, task, and reference information on installing, configuring, and using WebSphere ESB.
- In the WebSphere Service Registry and Repository documentation library contains announcement letters, demos, documentation, Redbooks, tutorials, Webcasts, and white papers.
- Learn more about WSRR WebServices Interfaces.