Thursday, February 24, 2011

Correlation in Oracle B2B 11g

In Oracle B2B 10g, it was not possible to correlate all the type of documents. Correlation was possible only for B2B protocols which support correlation as part of their specification/implementation like RosettaNet (through PIP) and ebMS (through "Conversation_ID"). For rest of the document types, we have to rely on middleware to have content-based correlation.

Now, Oracle B2B 11g has come up with an out-of-box support for correlation for all the type of xml-based documents. By just specifying X-Path in "Correlation" tab of Document Definition, all the XML-based documents can now be correlated. In "Correlation" tab there are four fields -
 


1. Correlation From Xpath Name
2. Correlation From Xpath Expression
3. Correlation To Xpath Name
4. Correlation To Xpath Expression
 
"Correlation From" fields should be set for the document definitions which start a collaboration (e.g. Purchase Order Request). "Correlation To" fields should be set for the document definitions which participate in a collaboration and gets correlated with a document definition which started that particular collaboration (e.g. Purchase Order Response)




At runtime, when a document passes from Oracle B2B which starts a collaboration, Oracle B2B will extract the value of correlation property/content of message by using Xpath expression provided in "Correlation From Xpath Expression" and store it with business message details of that message. When a document arrives at Oracle B2B, which participates in a collaboration, then Oracle B2B extracts the value of correlation property/content of message by using Xpath expression provided in "Correlation To Xpath Expression" and compares it with already existing correlation property/content of message of those messages which have already started a collaboration. When a match found, correlation happens. If no match found, then a new collaboration gets created.

Let's understand in depth that how correlation should be implemented in Oracle B2B 11g for any XML-based document, by an example.

In this example, I will use "Custom" XML document type. I am assuming that OracleServices is my host trading partner and MarketInc is a remote trading partner. Now flow will be like this -




1. OracleServices will send a PurchaseOrderRequest PO to MarketInc
2. MarketInc will send a PurchaseOrderResponse PO back to the OracleServices
3. Request and Response messages will be correlated on the basis of PO ID which is a required field in both request and response PO XSD's


I am using below XSD's for PurchaseOrderRequest and PurchaseOrderResponse respectively-



<?xml version= '1.0' encoding= 'UTF-8' ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.oracle.com/ns/order"
xmlns:po="http://xmlns.oracle.com/ns/order" elementFormDefault="qualified">
<element name="PurchaseOrderRequest" type="po:PurchaseOrderRequestType"/>
<complexType name="PurchaseOrderRequestType">
<sequence>
<element name="CustID" type="string"/>
<element name="ID" type="string"/>
<element name="productName" type="string" minOccurs="0"/>
<element name="itemType" type="string" minOccurs="0"/>
<element name="price" type="decimal" minOccurs="0"/>
<element name="quantity" type="decimal" minOccurs="0"/>
<element name="status" type="string" minOccurs="0"/>
<element name="ccType" type="string" minOccurs="0"/>
<element name="ccNumber" type="string" minOccurs="0"/>
</sequence>
</complexType>
</schema>



<?xml version= '1.0' encoding= 'UTF-8' ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.oracle.com/ns/order"
xmlns:po="http://xmlns.oracle.com/ns/order" elementFormDefault="qualified">
<element name="PurchaseOrderResponse" type="po:PurchaseOrderResponseType"/>
<complexType name="PurchaseOrderResponseType">
<sequence>
<element name="ID" type="string"/>
<element name="status" type="string" minOccurs="0"/>
</sequence>
</complexType>
</schema>


 
As you can see, both the XSD's have an element, named "ID" which would actually hold the PO ID and will be unique for each and every PO.

Now login to your B2B console and go to "Administration --> Document" section and create new version "1.0" under Custom document. Also create the Document Types PurchaseOrderRequest and PurchaseOrderResponse and under them Document Defintions PurchaseOrderRequestDocDef and PurchaseOrderResponseDocDef respectively as shown below -










Following are the "Identification Expression (Xpath)" setting for PurchaseOrderRequestDocDef & PurchaseOrderResponseDocDef respectively -


//*[local-name()='PurchaseOrderRequest']
//*[local-name()='PurchaseOrderResponse']


As always a PurchaseOrderResponse PO would need to be correlated with PurchaseOrderRequest (and NOT the vice-versa because a PurchaseOrderRequest will always have a unique PO ID), hence PurchaseOrderRequest PO is starting the collaboration and PurchaseOrderResponse PO will participate in a collaboration on the basis of it's correlation with a PurchaseOrderRequest.

Now go to "Correlation" tab of PurchaseOrderRequestDocDef and provide value "POID" in "Correlation From XPath Name" setting & value "//*[local-name()='ID']" in "Correlation From XPath Expression" setting -









Similarly, provide the values "POIDRes" & "//*[local-name()='ID']" in settings "Correlation To XPath Name" & "Correlation To XPath Expression" respectively of PurchaseOrderResponseDocDef -








Now add the documents to the Remote TP "MarketInc" configuration. Go to "Partners --> MarketInc --> Documents" and click on the green plus (+) button on the right side to select the document definitions. Add both document defintions PurchaseOrderRequestDocDef & PurchaseOrderResponseDocDef into "MarketInc" configuration and select the "Sender" & "Receiver" checkboxes appropriately -








Now create a channel under channels tab for MarketInc TP-










Now create a channel under "Host TP (OracleServices)-->Channels" tab. This channel will move all the inbound documents to a FILE location (Make sure that this channel is marked as "internal" under "Channel Attributes") -








Now create the agreements for both the document definitions between OracleServices & MarketInc. Save, validate & deploy the agreements as well -












Create two listening channels under "Administration --> Listening Channel" tab – one "internal" listening channel for sending outbound documents to Oracle B2B and another external (non-internal) listening channel for receiving inbound documents from Remote TP's -










Now you are ready to test this configuration. I used below request and response XML's for testing -


<?xml version="1.0" encoding="UTF-8"?>
<po:PurchaseOrderRequest xsi:schemaLocation="http://xmlns.oracle.com/ns/order po.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:po="http://xmlns.oracle.com/ns/order">
<po:CustID>111-11-1111</po:CustID>
<po:ID>PO123456</po:ID>
<po:productName>Laptop</po:productName>
<po:itemType>String</po:itemType>
<po:price>150.00</po:price>
<po:quantity>2</po:quantity>
<po:status>Order</po:status>
<po:ccType>New</po:ccType>
<po:ccNumber>1234-1234-1234-1234</po:ccNumber>
</po:PurchaseOrderRequest>




<?xml version="1.0" encoding="UTF-8"?>
<po:PurchaseOrderResponse xsi:schemaLocation="http://xmlns.oracle.com/ns/order po.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:po="http://xmlns.oracle.com/ns/order">
<po:ID>PO123456</po:ID>
<po:status>Approved</po:status>
</po:PurchaseOrderResponse>


Save request XML with name "MarketInc_PurchaseOrderRequest_1.0_1_123456788.xml" (format is ToTPName_DocType_DocTypeRevision_MsgType_MsgId.xml) & response XML with name "MarketInc_123455789.xml" (format is FromTPName_MsgId.xml).

Now copy & paste the request XML in internal listening channel directory. Make sure that after few seconds it gets deleted from there and a file gets created in the Remote TP Channel directory. Once the outbound flow is completed (a file gets created in Remote TP Channel's directory), copy & paste the response XML in external listening channel directory. Make sure that after few seconds it gets deleted from there and a file gets created in the Host TP Channel directory.

Now goto to "Reports" section on B2B console and in "Business Message" reports, open the details of response message. You will see that "Refer To Message" field is enabled and if you click on it, it will take you to the request message details. Moreover, if you scroll down on details, you would be able to see correlation related information as well -






If you open the "Conversation Message" report then there also you would see a collaboration created. If you select that collaboration, it would show you both the request and response business messages, listed under section "Conversation Details" -




 
You are done with implementing correlation in Oracle B2B 11g. Now go ahaed and experiment more with it.

Wednesday, February 16, 2011

B2B Console/SOA Composer Not Opening Up in Oracle SOA 11gR1 PS3 (11.1.1.4.0)


If you have just installed Oracle SOA Suite 11gR1 PS3 (11.1.1.4.0) and created a domain by selecting “Developers” templates (Oracle SOA Suite for developers – 11.1.1.0 [Oracle_SOA1]) then you might not be able to open B2B web-console or SOA composer console. When you try to open B2B console (or SOA composer) in browser it will show “Error--404 Not Found” -




Actually this is not an issue and that's how developers template is designed. Developers template has been introduced in PS3(11.1.1.4.0) for those developers who run SOA suite on a host which have lower memory capabilities. So to optimize the server memory usage, certain applications does not get targetted and (hence) deployed (including “b2bui”) by default when a server starts. The applications which does not get deployed by default, are -


1. FMW Welcome Page Application (11.1.0.0.0)
2. SocketAdapter
3. MQSeriesAdapter
4. OracleAppsAdapter
5. usermessagingdriver-xmpp
6. usermessagingdriver-smpp
7. usermessagingdriver-voicexml
8. usermessagingdriver-extension
9. b2bui
10. composer



If you login to Weblogic Admin console and go to “Deployments” section (In Domain Structure at left hand side), you will find that all above applications are in “Installed” state - 


These applications are in “Installed” state because they do not get targetted to any server by default. If you want to use these applications, then you have to manually target these applications to appropriate server, once after creating the domain. As in “Developers” template, only a single admin server gets created for hosting SOA (BPM & OSB, if chosen) applications and a BAM managed server gets created to host BAM applications, hence all SOA (BPM & OSB) related resources must be targetted to “AdminServer


Let's see how this targetting should be done. I will show you how to do it for “B2BUI” application which is a Web-App, you may do this similarly for other applications as well, as and when required.

Login to Weblogic Admin console and go to “Deployments” section (In “Domain Structure” at left hand side) -
 

Click Customize this table at the top of the Deployments table.


Change the number of rows per page to 100

Select the checkbox to exclude libraries and click Apply

Above steps are required for your convenience so that you may see all relevant deployments in one page. Above steps will need to be performed once only after creating the domain.


Now, click on the “b2bui” application name on the same page -



Go to “Targets” tab, select all components and click on “Change Targets” -




Select “AdminServer” in “Target Deployments” screen and click on “Yes” -




Make sure that “Current Target”section, now shows “AdminServer” for all components and you see the success message on Weblogic Admin Console -



Now, try to open B2B web-console in a web-browser and it should get opened -


Enjoy B2B 11gR1 PS3 now!! :)


You may similarly target “composer” application to AdminServer to open up SOA composer console(http://host:port/soa/composer).