Tutorials
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Data transformation is the mapping of data from one format to another. This section describes how BEA AquaLogic Service Bus routes messages and transforms messages, when necessary, according to specific criteria that you configure for a proxy service.
This section includes the following topics:
Complete Tutorial 1. Routing a Loan Application.
The goal of the tutorial is to provide the steps to create and test a routing and transformation scenario developed using the graphical environment provided in AquaLogic Service Bus Console.
Using the AquaLogic Service Bus Console you will build on what you learned in Tutorial 1. Routing a Loan Application, to:
A primary mortgage company uses BEA AquaLogic Service Bus to identify and re-route loan applications that can be sold to secondary loan companies. Loan applications with a principal request of greater than 25,000,000.00 are candidates for sale to a secondary loan company. When AquaLogic Service Bus receives a loan application meeting these criteria, the applicant's credit rating information is retrieved (by making a callout to a Web service) and added to the loan application, then the application is forwarded to the secondary mortgage company's Web service to be processed.
Loan applications with a principal request equal to or less than 25,000,000.00 are routed to a different business service for processing.
The target business services respond indicating whether the loan application is approved or rejected.
The following figure illustrates where BEA AquaLogic Service Bus fits in your enterprise to mediate the messaging between the enterprise services and the business services.
Figure 4-1 Expose a Loan Application Processing Web Service via AquaLogic Service Bus
A primary mortgage company receives a loan application. It is routed through the AquaLogic Service Bus proxy service, LoanGateway2
, to determine the target business service to process the application. If the loan amount is greater than 25000000
, the application is routed to the LoanSaleProcessor
business service. If the amount is less than or equal to 25000000
, the application is routed to the NormalLoan
business service. When the loan amount is more than 25000000
, the request pipeline makes a service callout to the CreditRatingService
and receives the credit rating of the applicant using the $creditRating
variable. To satisfy the interface requirements of the secondary loan company service, the message body is transformed by adding the credit rating details. The transformed message ($body
) is routed to a business service that handles applications for large loan amounts. The service returns a response of:
Loan Application Response: CREDIT RATING: AA: LOAN PURCHASED BY THE <i><b>LARGE</b></i> LOANS SERVICE
You will use the Project folder, MortgageBroker
, and the directory structure you created in the previous tutorial to hold the project artifacts. The resources required for this scenario are described in the following table.
Table 4-1 Routing a Loan Application Tutorial Resources
In this tutorial, you will build on what you learned in Tutorial 1. Routing a Loan Application—you will import additional WSDL resources, register new business and proxy services, and configure the routing behavior for the proxy service. Configuring the routing behavior includes:
CreditRating
element in the outbound (request) messageCreditRating
element on the response message.Complete the following steps to design and configure the proxy service and the associated resources in AquaLogic Service Bus to resolve this user case scenario:
Ensure that AquaLogic Service Bus is running in the domain you created for the tutorial and that you have completed the steps described in Tutorial 1. Routing a Loan Application.
For this tutorial, you use the project folder, MortgageBroker
, and the directory structure you created in Tutorial 1. Routing a Loan Application to hold the project artifacts.
In this step, you will import the WSDL resource, and create the proxy service and the business services required for the tutorial:
Because the WSDLs are the basis on which you create the business services and the proxy service, you must create the WSDL resources (LoanSale and CreditRatingService) before creating the other resources required for this scenario.
To import the appropriate WSDLs and create the WSDL resources, follow the steps described in To Import a WSDL, but for this instance, name your resources and base them on the WSDLs as described in the following table.
Table 4-2 WSDL Configuration Settings
When you complete this step, the MortgageBroker/WSDL
folder contains the WSDL resources created in this tutorial and in Tutorial 1. Routing a Loan Application as shown in the following figure.
In this step, you create a proxy service. The proxy service is used to route the loan application to the appropriate business service. It also calls a look up service to get the credit rating of the requestor if the loan amount requested is greater than 25 000 000.00. (Note that no units are assigned to the loan amount; it can be dollars or any other unit of currency.)
To create a new proxy service, follow the steps described in To Create the Proxy Service, but for this instance, use the proxy service name and the Endpoint URI described in the following table.
Table 4-3 Proxy Service Configuration Settings
Select the Select the |
|
After you complete this step, a summary of the configuration settings for the proxy service is displayed as shown in the following figure. Review the configuration settings prior to registering the proxy service.
Figure 4-3 LoadGateway2 Proxy Service - Configuration Settings Summary
When you complete this step, the MortgageBroker/ProxyService
folder contains the proxy services you created in this tutorial and in Tutorial 1. Routing a Loan Application as shown in the following figure.
Figure 4-4 Proxy Service Resources
In this scenario, the proxy service is configured to route to one of several different business services, depending on the business requirements:
You created the Normal Loan service in Tutorial 1. Routing a Loan Application. To create the LoanSaleProcessor
and CreditRatingService
business services for this scenario, follow the steps described in To Create the Normal Loan Business Service. However, in this case, configure your services using the names, service types, and endpoint URIs described in the following tables.
Table 4-4 Configuration Settings for the LoanSaleProcessor Business Service
Select the Select the |
|
Ensure that the pre-populated value for the Endpoint URI in the Existing URIs field is where For more information, see Edit the examples.properties File. |
Table 4-5 Configuration Settings for the CreditRatingService Business Service
Select the c Select the |
|
Ensure that the pre-populated value for the Endpoint URI in the Existing URIs field is where For more information, see Edit the examples.properties File. |
When you complete this step, the MortgageBroker/BusinessService
folder contains the business services you created in this tutorial and in Tutorial 1. Routing a Loan Application as shown in the following figure.
Figure 4-5 Business Service Resources
By completing Step 1: Prepare Your Environment to Step 3: Create the Resources, you created the resources required for this scenario. You configured the proxy service with a base configuration. Subsequent steps (Step 4: Configure the Routing for the LoanGateway2 Proxy Service to Step 6: Configure the Routing Table Response Actions for the LoanGateway2 Proxy Service) describes how to complete the configuration of the proxy service to add the routing, transformation, and Service Callout behavior for the loan application messages.
The proxy service is implemented in Service Bus as a Message Flow, which includes request and response pipelines. This step includes the following tasks:
The Resource Browser pane is opened in the navigation panel and the Summary of proxy Services page is displayed in the console.
Note: You must be in a session to edit resources. If you have not already done so, begin a session (click Create in the Change Center) so that you can configure the proxy service and edit the message flow.
LoanGateway2
proxy service, click the Edit Message Flow icon The Edit Stage Configuration page changes to display routing table configuration page.
You will configure the routing table to route messages to business services based on evaluating the amount
element of the incoming message. You must create an XQuery expression to do this. You can do so using the XQuery Expression Editor.
A graphical representation of the structure of the loan request document is displayed.
At run time, the proxy service makes its routing decision based on the value in the amount
element of the message.
Amount
node element, drag and drop it in the XQuery Expression text box. Note: The drag and drop functionality works only in Internet Explorer (IE) browsers. If you are using a browser other than IE, select the amount
element in the Variable Structures pane. The expression is displayed in the Property Inspector palette. Place the cursor in the XQuery expression text box and click Copy Property. The expression is copied to the text box. You can also copy the expression in the palette and paste it into the XQuery Expression text box.
It is good practise to do this before you submit the expression. The expression is validated for syntax. If there are errors in the expression, they are displayed directly above the Validate button. In this case, the expression is valid as shown in the following figure.
Figure 4-6 Validate Routing Expression
You are returned to the routing table on the Edit Stage Configuration page. <Expression>
is now replaced by the expression that returns the value of the amount
element in the message.
The routing table now contains an expression that determines the routing behavior. If the value in the Amount
field is greater than 25000000, then messages are routed according to the routing table configuration.
Service
link to define the service to which you want to route when the amount is greater than 25000000. The Select Service browser window is displayed.You have now defined the case for routing the loan application to the LoanSaleProcessor
business service.
Figure 4-7 Routing the Loan Application to LoanSaleProcessor
When a loan application with the amount of the loan greater than 25000000 is identified, a Web service callout (Service Callout) is performed to retrieve the customer's credit rating. The credit rating information is added to the loan application and the application is then forwarded to the secondary mortgage company's business service to be processed. The next section (Step 5: Configure the Routing Table Request Actions for the LoanGateway2 Proxy Service) describes how to configure the proxy service to do the Service Callout and transform the message appropriately for the target service.
To configure the Routing Table Request actions, execute the following steps:
A Service Callout is used to send the loan application to the CreditRatingService
business service, which returns the credit rating of an applicant. Before configuring the Service Callout action, you must assign an input parameter for the Service Callout action as follows:
body
from the Variables Structures drop-down list in the Variables Structures pane, then expand the element list and drag the loanRequest
element and drop it into the XQuery expression text box. The XQuery expression is written in the text box:$body/exam:processLoanApp/loanRequest
Figure 4-8 Configure Service Callout Input Parameter
This step completes the assignment of the value returned by the XQuery expression ($body/exam:processLoanApp/loanRequest) to the inputparam
variable.
This section describes how to configure the Service Callout action to send the loan application to the CreditRatingService
business service, which returns the credit rating of an applicant.
This step completes the configuration of the Service Callout to the CreditRatingService
Web Service. The credit rating returned by the Web service is assigned to the creditRating
context variable.
In this section, you will configure the transformation of the message to match the public contract (interface requirements) of the loanSaleProcessor
Service. Specifically, this section describes how to:
The body
context variable holds the body of the message. By completing these steps, you created a condition in which the XPath expression finds all the namespaces with the java
prefix in the body
context variable. The next step specifies the namespace with which to replace the namespaces identified by the XPath expression.
java:large.client
.Note: The namespace that you are replacing in this case is java:normal.client
.
The Rename action should now look like the following figure.
Figure 4-11 User Defined Namespace
<lg:CreditRating>{data($creditRating)}</lg:CreditRating>
java:large.client
namespace. Therefore you specify the namespace for the element with lg:.{}
tells the XQuery engine that the content between the {}
is not XML and must be interpreted. At run time, the $creditRating
variable is assigned a credit rating value by the credit rating service (to which we configured a Service Callout action in Add a Service Callout Action).
Note: It is good practice is to validate your expressions before submitting them.
Note: The drag and drop functionality works only in Internet Explorer (IE) browsers. If you are using a browser other than IE, select the notes
element in the Variable Structures pane. The XPath expression is displayed in the Property Inspector palette. Place the cursor in the XPath expression text box and click Copy Property. The expression is copied to the text box. You can also copy the expression in the palette and paste it into the XPath Expression text box.
./exam:processLoanApp/loanRequest/lg:Notes
The Insert action should now look like the following figure.
Figure 4-12 Insert New Element into Message
This step completes the configuration of the outbound message. You added a credit rating element to the message and changed the namespace so that the message complies with the public contract (interface) of the target service.
After completing the above steps, the configuration of the outbound message should look like the following figure.
Figure 4-13 Configuration of Outbound Message
The next step describes how to configure the response actions for the LoanGateway2
proxy service.
This step describes how to configure the response actions in the Routing Table so that the message that is returned by the proxy service to the client complies with the client's public contract (WSDL). Specifically, this section describes how to:
java:normal.client
. This configuration is described in To Add a Rename Action.By completing these steps, you have specified that AquaLogic Service Bus removes the credit rating element from the response message as the message is processed in the response pipeline.
This section describes how to rename the namespace to the namespace required by the client, that is java:normal.client
. (Recall that you configured the request message to the loanSaleProcessor
business service to change the namespace to that required by that service. (See To Rename the Namespace.)
After completing the above steps, the configuration of the response action of the proxy service should look like the following figure.
Figure 4-16 Configuration of Response Actions of Proxy Service
The last step in the configuration of the routing table for the LoanGateway2 proxy service is to add a default routing case (an else condition) to the Case expression.
This step describes how to configure a default routing case for the routing table for the LoanGateway2 proxy service. At run time, AquaLogic Service Bus routes messages according to the configuration of this default case if none of the conditions configured in the Routing Table is met.
processLoanApp
as shown in the following figure.Figure 4-17 Add Default Routing Case
You can view the map of the message flow of the proxy service as shown in the following figure.
Figure 4-18 Map of Message Flow of the LoanGateway2 Proxy Service
Now that you have configured AquaLogic Service Bus to work with the client and the target business services, you can test your configuration. The routing behavior of the proxy service in this scenario is based on the value of the loan amount in the loan application message. Changing the value of the loan amount changes the routing behavior.
normalLoan
business service. LoanSaleProcessor
business service (the large loan processing service).This section describes how to test the proxy service for both cases. The message returned in the command window after running a test indicates the success or failure of the test and identifies the business service that processed the request.
This section includes the following test scenarios:
BEA_HOME
\weblogic91\samples\servicebus\examples\src\
setEnv.cmd
Note: If you are testing the configuration on a UNIX system, run the setEnv.sh
script at your command line prompt.
BEA_HOME
\weblogic91\samples\servicebus\examples\src\examples\webservices\jws_basic\normal
build.xml
file run target:
<arg line="http://$...
<arg line="http://${wls.hostname}:${wls.port}/loan/gateway2 steve 555 25000001 20 5.1 notes" />
This changes the URI to that of the proxy service to that of the deployed Web service (gateway2
) running in the tutorial domain, and specifies a value of 25000001
for the loan amount. (For more information about the input parameters for the test, see Table 3-5.)
ant
run
The response message indicates that the Large Loan Service processed the request because the amount of the loan requested was 25000001 (greater than 25000000).
build.xml
file in the following directory:
BEA_HOME
\weblogic91\samples\servicebus\examples\src\examples\webservices\jws_basic\normal
In this case (to test the normalLoan
business service), in the build.xml
file, enter a value of 25000000
for the loan amount (see Table 3-5), then save the changes.
ant run
The response message indicates that the Normal Loan Application Processing Service processed the request because the amount of the loan requested was 25000000.
In this tutorial, you configure the transformation and replace the namespaces in the Route node. Alternatively, it is possible to configure the same logic in the request pipeline in a pipeline pair.
The work you must do to accomplish the transformation and namespace replacement is the same regardless of the model you choose.
In the case of the tutorial scenario, it is easier to add the actions to the request and response actions of the existing route node rather than create a separate pipeline pair, add a stage, and then add the transformation actions to that stage.
The following scenario describes a situation in which the choice of the implementation is important:
A route node routes messages to five different services. Each service requires the same transformation. In this scenario, it is better practice to add a single transformation to a request pipeline rather than configure five identical sets of transformations for each routing configuration in each route node. The run-time execution cost is the same, but the cost of maintaining, configuring, and understanding the latter implementation is higher and more work intensive.
![]() ![]() |
![]() |
![]() |