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
"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 -
<?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 -
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.