Wednesday 15 June 2011

OSB-BAM Integration Approach—Part 2

In http://shrikworld.blogspot.com/2011/06/osb-bam-integration-approachpart-1.html I explained how we can integrate BAM with OSB via BAM JCA Adapter.But there are other methods as well.In this blog I’ll explain how to leverage BAM Enterprise Message source for OSB Integration.

Before get started I’ll recommend to go through http://beatechnologies.wordpress.com/2011/05/20/integrating-oracle-bam-11g-with-bpel-jms-sensor-action/ blog which explains how to set up enterprise messaging source in BAM.I’ll extend that in my blog,so basically we need to enter data to JMS queue from OSB Business service.

Here are the steps of creating business service in OSB,

image

image

Now you have to provide endpoint URI for JMS, in my case soa.bam.cf connection factory and queue.bam.sensor queue are already created in admin server.

image

image

That’s all , we are now ready to test, just run business service,

image

Now go the metrics of messaging service,You will find 1 row committed to ADC.

image

Now you can prepare your custom report based on that data object.

Monday 13 June 2011

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,

image

Open Jdeveloper and create a BAM adapter on external reference swim lane which points to SalesOrder data object that you just created,

image

Then copy paste the following Jdeveloper artifacts to a folder of your OSB project,

image

Refresh the eclipse project and you can see all newly added components,

image

Create a business service out of .jca file, you need not to change anything there just save the generated .biz file.

image

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.

image

image

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,

image

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,

image

Design the message flow and in the replace activity add the below properties,

image

image

That’s all now we are ready to test , I assumed that you added the required value in BAM Adapter and updated the same,

image

Now run the proxy service and give some value, the data should be inserted into SalesOrder object,

image

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.

Wednesday 8 June 2011

Getting started with B2B11g

Lets go through a simple B2B interaction in SOA11g.I think B2B 11g is little bit simpler than 10g , anyways I hope after going through the post you will be able to configure B2B quite easily.

I’ve two B2B server and PO.xsd to start with.You can create your own PO xsd file by Jdeveloper or take any standard one.For one B2B server set A as host trading partner and D as external trading partner(say server1 or S1). For other server just do the reverse like D as Host TP and A as external TP(say server2 or S2).

Our PO.XML interaction would be S2---->S1 via http channel over AS2.  To get started first upload your schema in document section of administrator tab of B2B console of both S1 and S2 as below,

image 

You can see in Identification Expression (XPath) I’ve given //*[local-name()='purchaseOrder'] where 'purchaseOrder' is the name of root element of my PO.XSD file.So you have to change accordingly based on your schema.This is required for custom xml document , can’t skip.

image

Now in S2 rename and add the TP as below,give your own name for host TP and client TP and put some AS2 identifier at profile section for TP D which will be used in agreement later on.

image

Provide some AS2 identifier for TP A as well in profile.

In the document section of TP D and A of S2 check the sender and receiver as below,

image

image

Now click on the channel tab of TP A and create a AS2-1.1 channel from drop down list.In the URL section of Transport Protocol Parameters provide the B2B http lister channel URL of S1.

image

B2B HTTP lister channel has http://<hostname:8001>/b2b/httpreceiver URL so in our case it would be http://S1:8080/b2b/httpreceiver (replace S1 with actual name).

Now Auto Create agreement as below and provide listener channel of TP A in the agreement from drop down.,

image

Save and deploy the agreement.

Now go back to S1 and configure Host TP A and client TP D as below,

image

Provide the exactly same AS2 Identifier for both TP A and D as you have given in S2.

In the document section of TP D and A of S1 check the sender and receiver as below,

image

image

Create agreement as below,

image

That’s all from B2B side.To test the configuration we have to send some data to S2 B2B from a SOA composite.Here is my composite to feed the data to Host TP D of S2,

image

So here I’m reading PO from a file and sending the same to B2B listener channel of TP D of S2 via B2B adapter.Here are main screenshot of B2B configuration wizard,

image

image

image

image

In the mediator assign the below B2B related property according your TPs as below,

image

Deploy the composite to S2.Place a PO.XML file in the polling directory and check the report section of both the B2B console of S1 and S2.

Hope it will work smoothly, try it out..