![]() ![]() ![]() ![]() ![]() ![]() |
Data transformation is the mapping of data from one format to another, to make information compatible in heterogeneous system environments. ALSB can be configured to route and transforms messages when necessary, based on specific proxy service configurations.
This section includes the following topics:
You must complete Tutorial 1. Routing a Loan Application before beginning this tutorial.
This tutorial provides the tasks to create and test a routing and transformation scenario developed using the graphical environment provided in ALSB Console. Using the ALSB Console you will build on what you learned in Tutorial 1. Routing a Loan Application to perform the following tasks:
A primary mortgage company uses ALSB to identify and re-route loan applications that can be sold to secondary loan companies. Loan applications with a principal request of greater than US $25 million are candidates for sale to a secondary loan company. When ALSB receives a loan application meeting these criteria, the applicant’s credit rating information is retrieved (by making a callout to a web service). The credit rating information is added to the loan application. The application is then forwarded to the secondary mortgage company web service to be processed. Loan applications with a principal request equal to or less than US $25 million are routed to a different business service for processing. The target business services respond indicating whether the loan application is approved or rejected.
Figure 4-1 illustrates where ALSB fits in your enterprise to mediate the messaging between the enterprise services and the business services.
A primary mortgage company receives a loan application. It is routed through the ALSB proxy service, LoanGateway2, to determine the target business service to process the application. If the loan amount is greater than US $25 million, the application is routed to the LoanSaleProcessor business service. If the amount is less than or equal to US $25 million, the application is routed to the NormalLoan business service. When the loan amount is more than US $25 million, the request pipeline makes a service callout to the CreditRating business service and receives the credit rating of the applicant using the $creditRating variable. To fulfill 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 similar to the following:
Loan Application Response: CREDIT RATING: AA: LOAN PURCHASED BY THE <i><b>LARGE</b></i> LOANS SERVICE
You will use the MortgageBroker project folder 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.
In this tutorial, you will perform the following tasks:
Ensure that ALSB is running in the domain that you created for the tutorial and that you have completed the tasks described in Tutorial 1. Routing a Loan Application.
For this tutorial, you need to use the MortgageBroker project folder, and the directory structure that you created in Tutorial 1. Routing a Loan Application to hold the project artifacts.
The project explorer pane is opened in the navigation pane and a project page is displayed in the console.
MortgageBroker
project tree to expose the subfolders containing the project artifacts:In this section , you will learn how to import the WSDL resource, and create the proxy service and the business services required for the tutorial.
You must create the WSDL resources (loanSale and creditRating) before creating the other resources required for this scenario. WSDL resources are the building blocks for creating the business and proxy services. To import the appropriate WSDLs and create the WSDL resources, follow the tasks described in To Create the normalLoan WSDL Resource section in Tutorial 1. Routing a Loan Application. However, for this instance, name your resources and base them on the WSDLs listed in the following table.
|
When you complete this task, the MortgageBroker/WSDL folder contains the WSDL resources created in this tutorial and in Tutorial 1. Routing a Loan Application as shown in Figure 4-2.
In this task, you will 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 obtain the credit rating of the requestor if the loan amount requested is greater than US $25 million.
Note: | No units are assigned to the loan amount, but units can be any currency such as US dollars. |
To create a new proxy service, follow the tasks described in To Create the Proxy Service. For this instance, use the proxy service name and the endpoint URI listed in the following table.
After you complete this task, a summary of the configuration settings for the proxy service is displayed as shown in Figure 4-3. You must review the configuration settings before to registering the proxy service.
When you complete this task, the MortgageBroker/ProxyService folder contains the proxy services that you created in this tutorial and in Tutorial 1. Routing a Loan Application as shown in Figure 4-4.
In this scenario, the proxy service is configured to route to one of several different business services, depending on the business requirements as follows:
You created the NormalLoan service in Tutorial 1. Routing a Loan Application. To create the LoanSaleProcessor and CreditRatingService business services for this scenario, follow the tasks described in Create the NormalLoan Business Service. You must configure your services using the names, service types, and endpoint URIs listed in the following two tables.
When you complete this task, the MortgageBroker/BusinessService folder contains the business services that you created in this tutorial and in Tutorial 1. Routing a Loan Application as shown in Figure 4-5.
Upon completing all the tasks from Prepare the Environment to Create the Resources you have created the resources required for this scenario. You have also configured the proxy service with a base configuration. In the following three tasks you will configure the proxy service by adding the routing, transformation, and Service Callout behavior for the loan application messages.
A proxy service is implemented in ALSB as a message flow, which includes request and response pipelines. This task includes the following tasks:
The Resource Browser pane is opened in the navigation pane and the Summary of Proxy Services page is displayed in the console.
Note: | You must be in an session to edit resources. |
RouteNode1
is added.The Edit Stage Configuration page changes to display the routing table configuration information.
To configure the routing table to route messages to business services based on the amount element of the incoming message, you must create an XQuery expression using the XQuery Expression Editor.
$body - processLoanApp
(request) element.$body/exam:processLoanApp/loanRequest/java:Amount
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 in the XQuery Expression text box. |
It is good practice 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 Figure 4-15.
The routing table is displayed 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 US $25 million, then messages are routed according to the routing table configuration.
processLoanApp
operation. This is the operation on the LoanSaleProcessor business service that is invoked at run-time if the amount of the loan requested in the loan application is greater than US $25 million.
You have now defined the case for routing the loan application to the LoanSaleProcessor business service as shown in Figure 4-16.
When a loan application with a loan amount greater than US $25 million 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. The application is then forwarded to the secondary mortgage company's business service to be processed.
This section describes how to configure the proxy service to do the Service Callout and transform the message appropriately for the target service.
A Service Callout is used to send the loan application to the CreditRating business service, which returns the credit rating of an applicant. Before adding the Service Callout action, you must configure the Service Callout input parameter by performing the following tasks:
You must delete the “xsi:type” attribute from the message by adding and configuring a Delete action as follows:
The Delete action is added to the Routing Table Request Action pipeline.
The configuration for the Delete action is therefore:
Delete ./exam:processLoanApp/loanRequest/@xsi:type
in variable body as shown in Figure 4-19.
You must now assign an input parameter for the service callout action as follows:
The Assign action is added to the Request Action pipeline in the Routing Table.
$body/exam:processLoanApp/loanRequest
loanRequestVariable
in the variable text box as shown in Figure 4-21.
This task completes the assignment of value returned by the XQuery expression ($body/exam:processLoanApp/loanRequest) to the loanRequestVariable
variable.
You must now rename the namespace of the input parameter you have assigned for the Service Callout using the tasks below:
.//java:*
This expression identifies every instance of a namespace with a prefix of java.
loanRequestVariable
. You have completed creating a condition in which the XPath expression finds all the namespaces with the java prefix in the loanRequestVariable context variable. The next task specifies the namespace to replace the namespaces identified by the XPath expression.
java:credit.client
.Note: | The default namespace that you are replacing in this case is java:normal.client. |
The Rename action is displayed as shown in Figure 4-23.
This section describes how you can configure the Service Callout action to send the loan application to the CreditRating business service, that returns the credit rating of an applicant.
The Service Callout action is added to the Request Action pipeline in the Routing Table.
CreditRating
.The service callout action will be displayed as shown in Figure 4-25.
loanRequestVariable
(the message context variable you defined in the preceding section).creditRating
as shown in Figure 4-27.
This task completes the service callout configuration to invoke the creditRating web service. The credit rating returned by this web service is assigned to the $creditRating
context variable.
In this section, you will configure the message transformation to match the public contract (interface requirements) of the LoanSaleProcessor business service. You will configure the proxy service to:
.//java:*
This expression identifies every instance of a namespace with a prefix of java.
body
. The body context variable contains the body of the message. You have completed creating a condition in which the XPath expression finds all the namespaces with the java prefix in the body context variable. The next task specifies the namespace to replace the namespaces identified by the XPath expression.
java:large.client
.Note: | The default namespace that you are replacing in this case is java:normal.client. |
The Rename action is displayed as shown in Figure 4-28.
The Insert action configuration fields are added to the Request Actions pane.
lg
.java:large.client
The new namespace is displayed in the User Defined Namespaces area in the Namespace Definitions palette as shown in Figure 4-29.
<lg:CreditRating>{data($creditRating)}</lg:CreditRating>
At run time, the $creditRating variable is assigned a credit rating value by the CreditRating business service. (This is the business service to which we configured a Service Callout action in section Add a Service Callout Action).
Note: | It is good practice is to validate the expression before you submit it. |
after
from the drop-down list.The following XPath expression is written to the text box
./exam:processLoanApp/loanRequest/java:Notes
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 in the XPath Expression text box. |
./exam:processLoanApp/loanRequest/lg:Notes
body
in the Variable text field (the last field in the expression). This is the context variable into which the new <CreditRating> element is inserted at run time.The Insert action will be displayed as shown in Figure 4-31.
This task completes the configuration of the outbound message. You have added a credit rating element to the message and changed the message namespace so that the message complies with the public contract (interface) of the target service.
The configuration of the outbound message will be displayed as shown in the following figures.
The next task describes how you can configure the response actions for the LoanGateway2 proxy service.
This section describes how you can 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). You can configure the proxy service to:
The Delete action configuration fields are added to the Routing Table Response Actions.
./exam:processLoanAppResponse/return/lg:CreditRating
where <processLoanAppResponse> is the WSDL operation that was invoked with the string Response appended to it, and return is the WSDL part name.
body
in the variable text field of the <XPath> in variable option in the Delete action. The configuration for the Delete action is therefore:
Delete ./exam:processLoanAppResponse/return/lg:CreditRating in variable body as shown in Figure 4-33.
You have configured ALSB to remove the <CreditRating> element from the response message, when the message is processed in the response pipeline.
This section describes how you can rename the namespace to the namespace that the client requires, that is java:normal.client.
Note: | Recall that you configured the request message to the LoanSaleProcessor business service to change the namespace to that required by that service. (See Rename the Message Namespace). |
The Rename action configuration fields are added to the Response Actions pipeline.
body
.java:normal.client
When these tasks are completed, you have specified that ALSB replaces all namespaces with the prefix lg: in the response message with java:normal.client
as shown in Figure 4-34.
After these tasks are complete, the response action configuration of the proxy service will be displayed as shown in Figure 4-35.
The last task 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 section describes how you can configure a default routing case for the routing table of the LoanGateway2 proxy service. At run time, if none of the conditions configured in the Routing Table are met, ALSB routes messages according to the configuration of this default case.
The default case is added after the routing table on the Edit Stage Configuration page.
The message flow map of the proxy service will be displayed as shown in Figure 4-37.
Figure 4-38 shows the complete route node for LoanGateway2.
This section describes how to test the loan application using the test console. To test the loan, you must first deploy the client jars in the WLS console. For more information see, Load the Client Application.
<loanRequest xmlns:java="java:normal.client">
<!--Optional:-->
<java:Name>Smith</java:Name>
<!--Optional:-->
<java:SSN>1234567</java:SSN>
<!--Optional:-->
<java:Rate>5</java:Rate>
<!--Optional:-->
<java:Amount>900000000</java:Amount>
<!--Optional:-->
<java:NumOfYear>10</java:NumOfYear>
<!--Optional:-->
<java:Notes>Large Loan Processing</java:Notes>
</loanRequest>
Accept other default settings and click Execute. The response as in Figure 4-39.
The response message indicates that the proxy service LoanGateway2 routes the application to LoanSale Processor processed the request because the amount of the loan requested is greater than US $25 million.
<loanRequest xmlns:java="java:normal.client">
<!--Optional:-->
<java:Name>Smith</java:Name>
<!--Optional:-->
<java:SSN>1234567</java:SSN>
<!--Optional:-->
<java:Rate>5</java:Rate>
<!--Optional:-->
<java:Amount>2000000</java:Amount>
<!--Optional:-->
<java:NumOfYear>10</java:NumOfYear>
<!--Optional:-->
<java:Notes>Normal Loan</java:Notes>
</loanRequest>
Accept other default settings and click Execute. The response as in Figure 4-40.
The response message indicates that the proxy service LoanGateway2 routes the application to NormalLoanApproval business service processed the request because the amount of the loan requested was less than US $25 million.
In this tutorial, you configured the transformation and replaced 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 that 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.
![]() ![]() ![]() |