Archive for July, 2011

Using Dynamic Routing in OSB

Dynamic Routing in OSB can be used when we want to determine the business service at runtime in the message flow. To store the information about the business services that can be used, we can use XQuery resource.

Consider a scenario where OSB has to route the incoming requests to 2 different services based on the CustomerType element value sent in the payload. So create a XQuery resource with the following contents. Observe that we are using the absolute path of business service in configuration as required by dynamic routing.

<Configuration>
<CustomerType value =’Privileged’>
<Service>DynamicRoute/BSSystem1</Service>
</CustomerType>

<CustomerType value =’Ordinary’>
<Service>DynamicRoute/BSSystem2</Service>
</CustomerType>
</Configuration>

Following is the XML schema that we use.

<xsd:schema targetNamespace=”http://xmlns.oracle.com/schema/Customer”
    xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:ns1=”http://xmlns.oracle.com/schema/Customer”>

    <xsd:complexType name=”Customer”>
<xsd:sequence>
<xsd:element name=”CustomerId” type=”xsd:string” />
<xsd:element name=”FirstName” type=”xsd:string” />
<xsd:element name=”LastName” type=”xsd:string” />
<xsd:element name=”MiddleName” minOccurs=”0″ type=”xsd:string” />
<xsd:element name=”CustomerType” type=”xsd:string” />
<xsd:element name=”Email” minOccurs=”0″ type=”xsd:string” />
<xsd:element name=”Mobile” minOccurs=”0″ type=”xsd:string” />
</xsd:sequence>
</xsd:complexType>

    <xsd:complexType name=”StatusMsg”>
<xsd:sequence>
<xsd:element name=”CustomerId” type=”xsd:string” />
<xsd:element name=”Response” type=”xsd:string” />
<xsd:element name=”ErrorCode” type=”xsd:string” minOccurs=”0″/>
<xsd:element name=”ErrorMessage” type=”xsd:string” />
</xsd:sequence>
</xsd:complexType>

    <xsd:element name=”Customer” type=”ns1:Customer” />
<xsd:element name=”StatusMsg” type=”ns1:StatusMsg” />
</xsd:schema>

Following is the WSDL that we will use for the proxy service:

<wsdl:definitions name=”CustomerService”
targetNamespace=”http://xmlns.oracle.com/wsdl/CustomerService”         xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”
    xmlns:ns1=”http://xmlns.oracle.com/schema/Customer” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
    xmlns:tns=”http://xmlns.oracle.com/wsdl/CustomerService” xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/”>
<wsdl:types>
<xsd:schema>
<xsd:import namespace=”
http://xmlns.oracle.com/schema/Customer”
                schemaLocation=”Customer.xsd” />
</xsd:schema>
</wsdl:types>

    <wsdl:message name=”CustomerCreate”>
<wsdl:part name=”parameters” element=”ns1:Customer” />
</wsdl:message>
<wsdl:message name=”CustomerCreateResponse”>
<wsdl:part name=”parameters” element=”ns1:StatusMsg” />
</wsdl:message>

    <wsdl:portType name=”CustomerServicePort”>
<wsdl:operation name=”CustomerCreate”>
<wsdl:input message=”tns:CustomerCreate” />
<wsdl:output message=”tns:CustomerCreateResponse” />
</wsdl:operation>
</wsdl:portType>

    <wsdl:binding name=”CustomerServiceBinding” type=”tns:CustomerServicePort”>
<soap:binding style=”document”
transport=”
http://schemas.xmlsoap.org/soap/http” />

        <wsdl:operation name=”CustomerCreate”>
<soap:operation soapAction=”CustomerCreate” />
<wsdl:input>
<soap:body use=”literal” />
</wsdl:input>
<wsdl:output>
<soap:body use=”literal” />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>

Create the required resources a proxy service based on the above WSDL, 2 business services and a XQuery resource with the contents shown above.

image

Create the message flow as shown below.

image

The first assign activity loads the XQuery resource and stores the contents of the file in variable ‘varConfig’. The second assign activity stores the value of customer type element in the payload in ‘varType’ variable using the xpath expression $body/cus:Customer/CustomerType/text().

For the dynamic routing the expression should resolve to the following XML snippet. The attribute isProxy has to be set to ‘true’ if routing the request to proxy service or ‘false’ if routing the request to business service. Operation name is optional as business service might  not be WSDL service always.

<ctx:route>
<ctx:service isProxy=’false’>absolute path of business service</ctx:service>
<ctx:operation>operation name</ctx:operation>
</ctx:route>

So for our case use the XML contents as shown in the below screenshot along with the XPath expressions to get the required values.

image

Deploy the configuration jar and test it from test console to verify its working as expected.

The sample jar can be download from the following location.

Advertisement

OEPE versions in OSB

As we know that Weblogic and OEPE installation are pre-requisites for OSB11g installation. Oracle had started shipping Weblogic bundled with Coherence and OEPE. Using this Weblogics installer is the best way to get compatible OEPE for a particular release. However, these are not available for 64-bit machines and need to do manual installation JDK, Weblogic using generic Installer, compatible OEPE version along with your required version of OSB 11g.

So you need to better understand compatible versions of OEPE for a particular OSB 11g release. The following shows the compatibility matrix:

OSB Weblogic Server OEPE
11.1.1.6.0
11.1.1.7.0
10.3.6 11.1.1.8.0
11.1.1.5.0 10.3.5 11.1.1.7.2
11.1.1.4.0 10.3.4 11.1.1.6.1
11.1.1.3.0 10.3.3 11.1.1.5

These versions of Oracle Enterprise Pack for Eclipse are available here.

SOA-INFRA Issue

I have installed SOA Suite and OSB several times but never observed an issue with soa-infra. I used Oracle DB Enterprise Edition in all these installations.

Today i have tried with SOA Suite 11.1.1.4 installation with XE database as i was just preparing an environment for developers for their practice. But observed an issue with soa-infra in EM console which showing it as down. So went to deployments in weblogic admin console and verified the status of soa-infra application and found it in ‘Failed’ status. So the first thing i tried out was starting the soa-infra from deployments section in admin console. When i did this, i encountered the following error:

ORA-04063: package body "DEV_MDS.MDS_INTERNAL_SHREDDED" has errors ORA-06508: PL/SQL: could not find program unit being called: "DEV_MDS.MDS_INTERNAL_SHREDDED" ORA-06512: at line 1

Solution:

  • Do ‘grant execute on dbms_lob to public’ in sqlplus using sys login.
  • Recompile the package DEV_MDS.MDS_INTERNAL_SHREDDED

Restart the server and verify that soa-infra is in Active status now. If the issue is not resolved drop the schema and recreate using the RCU. But before recreating, make sure that following environment variable is set when using XE database.

set RCU_JDBC_TRIM_BLOCKS=TRUE

SOA Suite 11g R1 Developers Guide

Ever since i have seen this post by Antony Reynolds, i wanted to grab my copy of this book. But the price of the book in India kept me away for some time. Finally last week i am able to get my copy of it.

The first sight of the book perplexed me as i was expecting the book to be of size similar to Thomas Erls’ book ‘Web Service Contract Design & Versioning for SOA’. But the contents of the book made me realize that the size does not matter always.

The book is well organized into 3 parts. Part-I  introduces the SOA architecture SCA, developing BPEL composites, endpoint virtualization using OSB and using JCA Adapters, Human workflows, Business Rules, Business Events and Business Activity Monitoring (BAM) that are components of Oracle SOA Suite. Part-II introduces the business requirements of a fictitious company and proceed with the development of application using SOA architecture by making use of the components described in Part-I. Finally the book ends with chapters on deployment, testing and security which constitutes Part-III of the book.

The first thing i did was the search for the following 2 things as i wanted to confirm the best practices from what i know currently:

  • Scheduling the BPEL processes
  • Way to differentiate System and Business faults in OSB

The above things are covered in Chapter 16 and Chapter 14 respectively.

I am reading the chapters in no sequence and i found the chapters Designing Service Contract (Chapter 11), Error Handling (Chapter 14) and Message Interaction Patterns (Chapter 16) very interesting as of now.

Though my recommendation does not add any brownie points, i recommend this book to novice to learn the basics of SOA Suite11g and to experts to get the quick summary.

I want to finish it off asap before somebody steals the book Smile.

Coherence in OSB

In one of our proxy services, we call one service to get credentials with which we can proceed with next service calls in the message flow. As anybody can guess, the credentials might remain same for a period of time (though based on the reset policy).

So if we can reduce number of service calls by caching the service results will increase the performance of the service. I felt that i have realized this very late Smileonce i started searching for this feature in OSB as i find number of articles on the same.

Using Oracle Coherence is the way to cache service results and ‘Result Caching’ is the feature of business service through which OSB can leverage coherence functionality. Thought of putting all my findings in one post but after seeing this article on OTN, i don’t dare to do that.

I have just taken this simple scenario to make a point on using coherence in OSB. The context explained over here may not be the right candidate if we are not aware of the credential reset policy. Then the credentials stored in cache may not be the right ones always and need to clear the cache. So the context has to be clearly ascertained to use coherence.

Currently in the process of finding the way to use coherence in BPEL.


Pages

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 379 other subscribers

Enter your email address to follow this blog and receive notifications of new posts by email.


%d bloggers like this: