Professional Documents
Culture Documents
Creating a Mediator for Routing Messages Creating an Asynchronous Request and Response Using Mediator
Legacy customer files are retrieved from a directory by an adapter service named ReadCust. The ReadCust adapter service sends the file data to the CustomerRouter Mediator. The CustomerRouter Mediator applies a filter to the XML message payload to determine whether the message should be routed to the USCustomer reference or CanadaCustomer reference. The CustomerRouter Mediator then transforms the message to the structure required by the adapter reference. The external reference delivers the message to its associated external application.
4. 5.
In the New Gallery, expand the General node, and select the Applications category. In the Items list, select SOA Application and click OK. The Create SOA Application wizard appears.
4.
In the Application Name field, enter CustomerRouter and then click Next. The Name your project page appears.
5.
In the Project Name field, enter CustomerRouterProject and click Next. The Configure SOA settings page appears.
6.
From the Composite Template list, select Empty Composite and then click Finish. The Application Navigator of Oracle JDeveloper is populated with the new application and the project, and the SOA Composite Editor contains a blank palette.
7.
Task 2 Create the CustomerRouter Mediator Service Component 1. From the Component Palette, select SOA.
2.
Drag and drop a Mediator icon in the Components section. The Create Mediator dialog is displayed.
3. 4. 5.
In the Name field, enter CustomerRouter. From the Templates list, select Define Interface Later. Click OK. A Mediator with name CustomerRouter is created.
Task 3 Create a File Adapter Service You must create a file adapter service named ReadCust to read the XML files from a directory.
Note: Mediator may process the same file twice when run against
Oracle Real Application Clusters (Oracle RAC) planned outages. This is because a file adapter is a non-XA compliant adapter. Therefore, when it participates in a global transaction, it may not follow the XA interface specification of processing each file only once.
1. 2.
From the Component Palette, select SOA. Select File Adapter and drag it to the Exposed Services swimlane. The Adapter Configuration wizard Welcome page is displayed.
3.
4. 5.
In the Service Name field, enter ReadCust. Click Next. The Adapter Interface page is displayed.
6.
Select Define from operation and schema (specified later) and click Next. The Operation page is displayed.
7. 8. 9.
In the Operation Type field, select Read File. In the Operation Name field, replace Read with ReadFile. Click Next. The File Directories page is displayed.
10. In the Directory for Incoming Files (physical path) field, enter the directory from
which you want to read the files. For example, enter C:\Customer\In.
11. Click Next.
Task 4 Create a File Adapter Reference 1. From the Component Palette, select SOA.
2.
Select File Adapter and drag it to the External References swimlane. The Adapter Configuration wizard Welcome page is displayed.
3.
4. 5.
In the Service Name field, enter USCustomer. Click Next. The Adapter Interface page is displayed.
6.
Select Define from operation and schema (specified later) and click Next. The Operation page is displayed.
7.
8. 9.
In the Operation Type field, select Write File. In the Operation Name field, enter WriteFile.
directory in which you want to write the files. For example, C:\Customer\out.
12. In the File Naming Convention field, enter customer_%SEQ%.xml and click
by using the CanCustomer.xsd file. Figure 14 shows how the SOA Composite Editor appears after performing this task.
Task 5 Specify Routing Rules You must specify the path that messages take from the ReadCust adapter service to external references.
1.
Connect the ReadCust service to the CustomerRouter Mediator, as shown in Figure 15. This specifies the file adapter service to invoke the CustomerRouter Mediator while reading a file from the input directory.
2. 3.
Double-click the CustomerRouter Mediator in the Mediator Editor. In the Routing Rules section, click Add to the extreme right side of ReadFile, and then click static routing rule. The Target Type dialog is displayed.
4.
5.
Navigate to CustomerRouterProject > References > USCustomer and select WriteFile, as shown in Figure 16.
6.
7.
Next to the <<Filter Expression>> field, click the filter icon to create a filter expression for this routing rule. The Expression Builder dialog is displayed.
8. 9.
In the Variables field, navigate to Variables> in > body > imp1:CustomerData, and then select Country. Double-click Country. The Country node is added in the Expression field, as shown in Figure 17.
The <<Filter Expression>> field of the Routing Rules section is populated with the expression.
12. To the right of the Transform Using field, click the icon.
14. Drag and drop the imp1:CustomerData source element to the imp1:Customer
Ancestor Names. The Auto Map Preferences dialog is shown in Figure 110.
Figure 110 Auto Map Preferences Dialog
17. From the File menu, select Save All. 18. Repeat the procedures mentioned in Step 3 through Step 17 to create a
CanadaCustomer reference as the target service. In the Expression Builder dialog, specify the following expression:
Note: For repeating the steps, you must re-enter the Mediator Editor
After performing all the steps described in this section, the SOA Composite Editor appears, as shown in Figure 11. Task 6 Create an Application Server Connection An application server connection is required for deploying your SOA composite application. Task 7 Deploy the CustomerRouterProject Deploying the CustomerRouterProject composite application to an application server consists of following steps:
I
Creating an application deployment profile Deploying the application deployment profile to an application server
Task 8 Run and Monitor the CustomerRouterProject Application After deploying the CustomerRouterProject application, you can run it by copying the input XML files to the input folder. The payload files are written to the specified output directories. For monitoring the running instance, you can use Oracle Enterprise Manager Fusion Middleware Control at the following URL:
http://hostname:port_number/em
where hostname is the host on which you installed the Oracle SOA Suite infrastructure and port_number is the port of the server on which Oracle Enterprise Manager Fusion Middleware Control is installed.
2. 3.
In the New Gallery, expand the General node, and select the Applications category. In the Items list, select SOA Application and click OK. The Create SOA Application wizard appears.
4.
In the Application Name field, enter AsyncMediator and then click Next. The Name your project page appears.
5.
In the Project Name field, enter AsyncMediatorSample and click Next. The Configure SOA settings page appears.
6.
In the Composite Template list, select Empty Composite and then click Finish. The Application Navigator of Oracle JDeveloper is populated with the new application and the project, and the SOA Composite Editor contains a blank palette.
7.
1. 2. 3.
Task 2 Create a Server BPEL Process In the Application Navigator, double-click composite.xml. The SOA Composite Editor is displayed. From the Component Palette, select SOA. Drag and drop a BPEL Process into the Components section. The Create BPEL Process dialog is displayed.
4. 5. 6.
In the Name field, enter ServerBPELProcess. From the Template list, select Asynchronous BPEL Process. Deselect Expose as a SOAP service and click OK. The ServerBPELProcess is created in the SOA Composite Editor.
Task 3 Create a Mediator Service Component 1. From the Component Palette, select SOA.
2.
Drag and drop a Mediator into the Components section. The Create Mediator dialog is displayed.
3. 4. 5. 6.
In the Name field, enter Mediator. From the Template list, select Asynchronous Interface. Deselect Create Composite Service with SOAP Bindings. Click OK. A Mediator with name Mediator is created, as shown in Figure 113.
Figure 113
7.
8.
In the Routing Rules section, click Add to the far right side of execute and then select static routing rule. The Target Type dialog is displayed.
9.
12. Below the <<Filter Expression>> field, click the icon to the right of the Transform
The XSLT Mapper is displayed and a target file named singleString_To_ process.xsl is added.
14. Drag and drop the cb1:input source element to the client:input target element.
Ancestor Names and click OK. The XSLT Mapper displays, as shown in Figure 115.
Figure 115 singleString_To_process.xsl Window
16. In the Routing Rules section, under Callback, click the icon to the right of the
The XSLT Mapper is displayed and a target file named processResponse_To_ singleString.xsl is added.
18. Drag and drop the client:processResponse source element to the cb1:singleString
Ancestor Names and click OK. Task 4 Create a Client BPEL Process 1. In the Application Navigator, double-click composite.xml. The SOA Composite Editor is displayed.
2. 3.
From the Component Palette, select SOA. Drag and drop a BPEL Process to the Components section. The Create BPEL Process dialog is displayed.
4. 5. 6.
In the Name field, enter ClientBPELProcess. From the Template list, select Asynchronous BPEL Process. Click OK. ClientBPELProcess is created in the SOA Composite Editor.
7.
Drag and drop the ClientBPELProcess BPEL process to the Mediator Mediator. The SOA Composite Editor appears, as shown in Figure 112.
Task 5 Create the Invoke Activity 1. Double-click ClientBPELProcess. The Oracle BPEL Designer is displayed.
2. 3. 4. 5. 6. 7. 8. 9.
Drag and drop an Invoke activity from the Component Palette to the design area. Double-click the Invoke activity. The Invoke dialog is displayed. In the Name field, enter InvokeMediator. Next to the Partner Link field, click Browse Partner Links. The Partner Link Chooser dialog is displayed. Select Operation - execute, and click OK. To the right of the Variable field in the Invoke dialog, click the Auto-Create Variable icon. The Create Variable dialog is displayed. In the Variable field, enter InvokeMediator_execute_InputVariable_1 and click OK. The Invoke dialog is displayed. Click OK. The Oracle BPEL Designer appears.
Task 6 Create the Receive Activity 1. Drag and drop a Receive activity from the Component Palette to the design area.
2. 3. 4. 5. 6. 7. 8.
Double-click the Receive activity. The Receive dialog is displayed. In the Name field, enter ReceiveFromMediator. Next to the Partner Link field, click Browse Partner Links. The Partner Link Chooser dialog is displayed. Select Operation - callback, and click OK. To the right of the Variable field in the Receive dialog, click the Auto-Create Variable icon. The Create Variable dialog is displayed. Select the default variable name and click OK. The Variable field is populated with the default variable name. Check Create Instance, and click OK. The Oracle BPEL Designer appears.
Task 7 Create the Assign Activity 1. Drag and drop an Assign activity from the Component Palette between the ReceiveFromMediator and InvokeMediator activities in the design area.
2. 3.
Double-click the Assign activity. The Assign dialog is displayed. In the Name field, enter AssignRequest.
4. 5. 6.
Click the Copy Operation tab. The Assign dialog is displayed. Select Copy Operation. The Create Copy Operation dialog is displayed. Create the copy operation between the triggers file name and the file variable, as shown in Figure 116.
The Create Copy Operation Dialog
Figure 116
7. 8.
Click OK in the Create Copy Operation dialog. Click OK to return to the Oracle BPEL Designer, as shown in Figure 117.
Figure 117
9.
Task 8 Create the Assign Activity in the ServerBPELProcess 1. Double-click the ServerBPELProcess BPEL process. The Oracle BPEL Designer is displayed.
2. 3. 4. 5. 6.
Drag and drop an Assign activity from the Component Palette between the receiveInput and callbackClient activities in the design area. Double-click the Assign activity. The Assign dialog is displayed. Click the Copy Operation tab. Select Copy Operation. The Create Copy Operation dialog is displayed. Create the copy operation between the triggers file name and the file variable, as shown in Figure 118.
Figure 118
7. 8.
Click OK in the Create Copy Operation dialog. Click OK to return to the Oracle BPEL Designer, as shown in Figure 119.
The Oracle JDeveloper - ServerBPELProcess.bpel
Figure 119
9.
Task 9 Configure an Application Server Connection An application server connection is required for deploying your SOA composite application. Task 10 Deploy the SOA Composite Application Deploying the EventMediatorApp composite application to Oracle WebLogic Server consists of following steps:
I