Tuesday, June 16, 2015

Dynamic partnerlink in OSB


Dynamic Partnerlink in OSB can be implemented in two ways.
1> URI override to achieve dynamic service invocation.
This sample is already provided by oracle and can be downloaded from the following link
http://java.net/projects/oracleservicebus1031/downloads/download/DYNAMIC-DISPATCH.zip
2> Dynamic routing based on input values.
When you do not know the service you need to invoke from the proxy service you are creating, you use dynamic routing. In this use case a scenario will be created where in, based on the input values business process will be invoked. Two business service will be created which will be writing data to two different folder. A proxy service will be created which will be exposed to client. This proxy service will be the entry point for the interface. Depending upon the input request from the proxy service one of the business service will be chosen at run time and the file will be written to the corresponding folder defined by business services. In order to choose the business service dynamically an XQuery file will be created which will contain the location of the business services. Based on input parameter the location of the business service will be retrieved from the XQuery file. This will be passed to a dynamic routing link which will route the request to the corresponding business service.

Create two business services which will write to two different folder location and name them as GoldClass and SilverClass.

Create two business Service to write file into a particular folder location. Here are the steps for one of the business process, the same steps can be followed to create other one too.
Create a business service of Any XML type




Make sure you already have created two folders named “GoldClass” and “SilverClass” where data file can be written to.
Choose file as protocol and add the GoldClass folder location as shown




Click on next and save the changes.



Follow the same steps and create one more business service for SilverClass.
Once completed you should be able to see the two business service in your folder.





Create an XML document for XQuery
Use the following xml document for the XQuery
Here logical name is the name which will come as input parameter from the client and the physical name is the name of the actual business service.
<routing>
<row>
<logical>Gold</logical>
<physical>default/GoldClass</physical>
</row>
<row>
<logical>Silver</logical>
<physical>default/SilverClass</physical>
</row>
</routing>

As you can see the physical location is nothing but the path of business service in OSB. Since we have created two business service GoldClass and SilverClass within Default folder the path to reach them will be default/GoldClass and default/SilverClass




Create an XQuery file and copy the contents




Create a proxy service



Keep the default properties and save the proxy service.
Save the Proxy service.
Edit the message flow.
Add a pipeline pair
Add a stage in request pipeline




Edit the Stage1
Add an assign activity and assign the XQuery to a temp variable. This is done so that later point of time it can be used




Retrieve the logical data from the input payload using the following XPath
$body/routing/row/logical
This assign activity will try to retrieve the logical location from the input parameter that will be passed from the proxy service.
Again use an assign activity and assign this value to another temp variable






Now use one more assign activity and this activity the actual physical location will be identified based on the logical input. Use the following routing code to retrieve the actual physical location and assign it to a temp variable. This code compares the logical identifier received from the proxy service and the logical identifier defined in XQuery file and output the corresponding physical location of the business service.
<ctx:route>
<ctx:service isProxy=’false'>
{$RouteTable/row[logical/text()=$logicalIdentifier]/physical/text()}
</ctx:service>
</ctx:route>






Save the output of this expression to a temp variable output.
This variable will now contain the actual location of the business service.
Save your process.
Go back to pipeline and add a route action





Add a dynamic routing and route it to the temp variable where you have retrieved the actual physical location of the business service. Since output is the variable where the actual location is saved we will use the same in dynamic routing.





Save the process and activate the changes.

Test the proxy service

Use following input






You will get the following invocation



No comments: