OSB-BAM Integration Approach–Part 1
I’ll show you how to integrate Oracle BAM with Oracle service Bus in SOA 11.1.1.5.Here I’ll leverage Oracle BAM JCA adapter to create Business Service to populate data in BAM ADC table.
Here are the detailed steps to configure BAM and OSB,
You need to create one data object in BAM Architect, you can create your own table, for mine here is the screenshot,
Open Jdeveloper and create a BAM adapter on external reference swim lane which points to SalesOrder data object that you just created,
Then copy paste the following Jdeveloper artifacts to a folder of your OSB project,
Refresh the eclipse project and you can see all newly added components,
Create a business service out of .jca file, you need not to change anything there just save the generated .biz file.
Now create a sales order xsd file which will be input parameter of a proxy service,
<?xml version = '1.0' encoding = 'UTF-8'?>
<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://shrikworld.blogspot.com/soa"
xmlns="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://shrikworld.blogspot.com/soa">
<annotation>
<documentation>
<info>/Order/SalesOrder</info>
</documentation>
</annotation>
<element name="SalesOrderCollection">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="SalesOrder"
type="tns:SalesOrder"/>
</sequence>
</complexType>
</element>
<complexType name="SalesOrder">
<sequence>
<element minOccurs="0" name="OrderID">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">SalesOrderID</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="OrderDate" type="xsd:dateTime">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderDate</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">datetime</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
</element>
<element minOccurs="0" name="CustomerNo">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">CustomerID</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="Discount">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderDiscount</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="OrderTotal">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderTotal</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="OrderLines">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderLines</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="ShipDate" type="xsd:dateTime">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">PromisedShipDate</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">datetime</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
</element>
</sequence>
</complexType>
</schema>
Now create a proxy service of service type messaging service as below,In the request message type upload the sales order xml schema as created above.
Your message flow would be very simple and within the replace activity your custom sales order field will be transformed to business service specific sales order,
For that you need to create one xquery like
(:: pragma bea:global-element-parameter parameter="$salesOrderCollection1" element="ns1:SalesOrderCollection" location="../adapter/BAMAdapterTest/xsd/SalesOrder.xsd" ::)
(:: pragma bea:global-element-return element="ns0:_SalesOrderCollection" location="../adapter/BAMAdapterTest/xsd/SOAVMBAMConn_Order_SalesOrder.xsd" ::)
declare namespace ns1 = "http://shrikworld.blogspot.com/soa";
declare namespace ns0 = "http://xmlns.oracle.com/bam";
declare namespace xf = "http://tempuri.org/DBAdapterTest/xq/SOIn2BAM/";
declare function xf:SOIn2BAM($salesOrderCollection1 as element(ns1:SalesOrderCollection))
as element(ns0:_SalesOrderCollection) {
<ns0:_SalesOrderCollection>
{
for $SalesOrder in $salesOrderCollection1/ns1:SalesOrder
return
<ns0:_SalesOrder>
{
for $OrderID in $SalesOrder/ns1:OrderID
return
<ns0:_SalesOrderID>{ data($OrderID) }</ns0:_SalesOrderID>
}
{
for $OrderDate in $SalesOrder/ns1:OrderDate
return
<ns0:_OrderDate>{ data($OrderDate) }</ns0:_OrderDate>
}
{
for $CustomerNo in $SalesOrder/ns1:CustomerNo
return
<ns0:_CustomerID>{ data($CustomerNo) }</ns0:_CustomerID>
}
{
for $Discount in $SalesOrder/ns1:Discount
return
<ns0:_OrderDiscount>{ data($Discount) }</ns0:_OrderDiscount>
}
{
for $OrderTotal in $SalesOrder/ns1:OrderTotal
return
<ns0:_OrderTotal>{ data($OrderTotal) }</ns0:_OrderTotal>
}
{
for $OrderLines in $SalesOrder/ns1:OrderLines
return
<ns0:_OrderLines>{ data($OrderLines) }</ns0:_OrderLines>
}
{
for $ShipDate in $SalesOrder/ns1:ShipDate
return
<ns0:_PromisedShipDate>{ data($ShipDate) }</ns0:_PromisedShipDate>
}
</ns0:_SalesOrder>
}
</ns0:_SalesOrderCollection>
};
declare variable $salesOrderCollection1 as element(ns1:SalesOrderCollection) external;
xf:SOIn2BAM($salesOrderCollection1)
Don’t worry you need not to write any code, there is a visual editor for that,
Design the message flow and in the replace activity add the below properties,
That’s all now we are ready to test , I assumed that you added the required value in BAM Adapter and updated the same,
Now run the proxy service and give some value, the data should be inserted into SalesOrder object,
Now create BAM report as per your need based on SalesOrder data object .So we can publish data to BAM from OSB via BAM adapter.
Here are the detailed steps to configure BAM and OSB,
You need to create one data object in BAM Architect, you can create your own table, for mine here is the screenshot,
Open Jdeveloper and create a BAM adapter on external reference swim lane which points to SalesOrder data object that you just created,
Then copy paste the following Jdeveloper artifacts to a folder of your OSB project,
Refresh the eclipse project and you can see all newly added components,
Create a business service out of .jca file, you need not to change anything there just save the generated .biz file.
Now create a sales order xsd file which will be input parameter of a proxy service,
<?xml version = '1.0' encoding = 'UTF-8'?>
<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://shrikworld.blogspot.com/soa"
xmlns="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://shrikworld.blogspot.com/soa">
<annotation>
<documentation>
<info>/Order/SalesOrder</info>
</documentation>
</annotation>
<element name="SalesOrderCollection">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="SalesOrder"
type="tns:SalesOrder"/>
</sequence>
</complexType>
</element>
<complexType name="SalesOrder">
<sequence>
<element minOccurs="0" name="OrderID">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">SalesOrderID</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="OrderDate" type="xsd:dateTime">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderDate</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">datetime</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
</element>
<element minOccurs="0" name="CustomerNo">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">CustomerID</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="Discount">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderDiscount</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="OrderTotal">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderTotal</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="OrderLines">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">OrderLines</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">string</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="xsd:string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="ShipDate" type="xsd:dateTime">
<annotation>
<appinfo>
<columnName xmlns="http://xmlns.oracle.com/bam">PromisedShipDate</columnName>
<columnType xmlns="http://xmlns.oracle.com/bam">datetime</columnType>
<columnDescription xmlns="http://xmlns.oracle.com/bam"/>
</appinfo>
</annotation>
</element>
</sequence>
</complexType>
</schema>
Now create a proxy service of service type messaging service as below,In the request message type upload the sales order xml schema as created above.
Your message flow would be very simple and within the replace activity your custom sales order field will be transformed to business service specific sales order,
For that you need to create one xquery like
(:: pragma bea:global-element-parameter parameter="$salesOrderCollection1" element="ns1:SalesOrderCollection" location="../adapter/BAMAdapterTest/xsd/SalesOrder.xsd" ::)
(:: pragma bea:global-element-return element="ns0:_SalesOrderCollection" location="../adapter/BAMAdapterTest/xsd/SOAVMBAMConn_Order_SalesOrder.xsd" ::)
declare namespace ns1 = "http://shrikworld.blogspot.com/soa";
declare namespace ns0 = "http://xmlns.oracle.com/bam";
declare namespace xf = "http://tempuri.org/DBAdapterTest/xq/SOIn2BAM/";
declare function xf:SOIn2BAM($salesOrderCollection1 as element(ns1:SalesOrderCollection))
as element(ns0:_SalesOrderCollection) {
<ns0:_SalesOrderCollection>
{
for $SalesOrder in $salesOrderCollection1/ns1:SalesOrder
return
<ns0:_SalesOrder>
{
for $OrderID in $SalesOrder/ns1:OrderID
return
<ns0:_SalesOrderID>{ data($OrderID) }</ns0:_SalesOrderID>
}
{
for $OrderDate in $SalesOrder/ns1:OrderDate
return
<ns0:_OrderDate>{ data($OrderDate) }</ns0:_OrderDate>
}
{
for $CustomerNo in $SalesOrder/ns1:CustomerNo
return
<ns0:_CustomerID>{ data($CustomerNo) }</ns0:_CustomerID>
}
{
for $Discount in $SalesOrder/ns1:Discount
return
<ns0:_OrderDiscount>{ data($Discount) }</ns0:_OrderDiscount>
}
{
for $OrderTotal in $SalesOrder/ns1:OrderTotal
return
<ns0:_OrderTotal>{ data($OrderTotal) }</ns0:_OrderTotal>
}
{
for $OrderLines in $SalesOrder/ns1:OrderLines
return
<ns0:_OrderLines>{ data($OrderLines) }</ns0:_OrderLines>
}
{
for $ShipDate in $SalesOrder/ns1:ShipDate
return
<ns0:_PromisedShipDate>{ data($ShipDate) }</ns0:_PromisedShipDate>
}
</ns0:_SalesOrder>
}
</ns0:_SalesOrderCollection>
};
declare variable $salesOrderCollection1 as element(ns1:SalesOrderCollection) external;
xf:SOIn2BAM($salesOrderCollection1)
Don’t worry you need not to write any code, there is a visual editor for that,
Design the message flow and in the replace activity add the below properties,
That’s all now we are ready to test , I assumed that you added the required value in BAM Adapter and updated the same,
Now run the proxy service and give some value, the data should be inserted into SalesOrder object,
Now create BAM report as per your need based on SalesOrder data object .So we can publish data to BAM from OSB via BAM adapter.
No comments:
Post a Comment