Home > OSB > OSB11G – Sample With Assign, Replace, Insert, ServiceCallOut, Log and XQuery

OSB11G – Sample With Assign, Replace, Insert, ServiceCallOut, Log and XQuery

In this example, I have shown how the OSB activities (Assign, Replace, Insert, ServiceCallout and Log) activities and XQuery transformation can be used to accomplish the sample requirement.

This is a WSDL based service. Two WSDL has been used.
1. Student.wsdl (ProxyService)
2. Customer.wsdl (BusinessService)

Downnload this EAR files and deploy it in weblogic service to get the “Student.wsdl” and “Customer.wsdl”
CustomerService-1.0.0.ear
StudentService-1.0.0.ear

Here the requirement considered as student is givinng his information using Student Sertvice and the informations has been inserted as Customer Details in an Organisation and returning the success massage after sucessfull insertion.

And this example shows how the above mentioned OSB activities used across flow to achieve the requirement.
Complete Flow would look like the below shown diagram.

CompleteFlow

CompleteFlow

Below is the Project Structure created for this sample.

ProjectStructure

ProjectStructure

1. Assign:
Assign the soap body received from consumer into a variable.

Assign

Assign

2. Log:
This activity will log the variable content to server log based on the LOG LEVEL set in server.
Defaultly the INFO level will be enabled in server.
The logs will be writtem to the following server location.
For OSB the log location : ${MW_HOME}/user_projects/domains/osb_domain/servers/osb_server1/logs/osb_server1.log

LogActivity

LogActivity

3. ServiceCallout:
OSB makes call to a Proxy or Business service to construct the message content using the message value received from ServiceCallout.
Here the activity has been used to retrieve the address by calling another proxy service.
Just passing the body variable and getting the response in address variable.

ServiceCallout

ServiceCallout

4. This OSB Proxy stub will respond back with address element for any request.

OSBProxyStub

OSBProxyStub

For any input “XPath” , replace response “body” with the below address element from Stub.

<sch:address>
            <sch:number>6</sch:number>
            <sch:street>Sutherland road</sch:street>
            <sch:city>Chatswood</sch:city>
            <sch:state>NSW</sch:state>
            <sch:zip>2067</sch:zip>
            <sch:country>Australia</sch:country>
</sch:address>

5. Insert:
This activity is used to insert this “address” element received as result of “ServiceCallout” activity into the request received from consumer.

Insert

Insert

6. Replace:
This is used to transform the enriched message of Student to Customer service and assign to request “body”.
Here the Xquery is used to transform the Student to Customer.
The log activity below is to verify the transformed Student request as Customer

Replace

Replace

XQuery Source

(:: pragma bea:global-element-parameter parameter="$processStudentRequest1" element="ns1:processStudentRequest" location="../xsd/Student.xsd" ::)
(:: pragma bea:global-element-return element="ns0:insertCustomerRequest" location="../xsd/Customer.xsd" ::)

declare namespace ns1 = "http://com.wordpress.student/Student/schema";
declare namespace ns0 = "http://com.wordpress.customer/Customer/schema";
declare namespace xf = "http://tempuri.org/XQuery_SB/resources/trasformations/XQ_Student_Customer_Request/";

declare function xf:XQ_Student_Customer_Request($processStudentRequest1 as element(ns1:processStudentRequest))
    as element(ns0:insertCustomerRequest) {
        <ns0:insertCustomerRequest>
        	<ns0:firstname>{ data($processStudentRequest1/ns1:student[1]/ns1:studentFirstName) }</ns0:firstname>
            <ns0:lastname>{ data($processStudentRequest1/ns1:student[1]/ns1:studentLastName) }</ns0:lastname>
            {
                for $address in $processStudentRequest1/ns1:student[1]/ns1:address
                return
                    <ns0:address>
                        <ns0:number>{ data($address/ns1:number) }</ns0:number>
                        <ns0:street>{ data($address/ns1:street) }</ns0:street>
                        <ns0:city>{ data($address/ns1:city) }</ns0:city>
                        <ns0:state>{ data($address/ns1:state) }</ns0:state>
                        <ns0:zip>{ data($address/ns1:zip) }</ns0:zip>
                        <ns0:country>{ data($address/ns1:country) }</ns0:country>
                    </ns0:address>
            }
            <ns0:age>{ data($processStudentRequest1/ns1:student[1]/ns1:age) }</ns0:age>
            <ns0:gender>{ data($processStudentRequest1/ns1:student[1]/ns1:gender) }</ns0:gender>
            <ns0:email>{ data($processStudentRequest1/ns1:student[1]/ns1:email) }</ns0:email>
            <ns0:phone>{ data($processStudentRequest1/ns1:student[1]/ns1:phone) }</ns0:phone>
        </ns0:insertCustomerRequest>
};

declare variable $processStudentRequest1 as element(ns1:processStudentRequest) external;

xf:XQ_Student_Customer_Request($processStudentRequest1)

7. Routing:
This Routing node is processing the request and response communication with another service.
As shown below the routing communicate with Customer service for inserting the student information.

Routing

Routing

BusinessService:

BusinessService

BusinessService

Download this OSB sample from here XQuery_SB.zip

Advertisements
Categories: OSB Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: