Monday, May 10, 2010

OSB: Dynamic Routing at test

I have defined a Business Service TestUpdateDB/BS/CompanyDBBS  (TestUpdateDB is the project name BS the folder name, CompanyDBBS the Business Service.... you are supposed to OMIT the .biz at the end of the BS).

If I configure the Dynamic Routing node with this Service field:

<ctx:route>
<ctx:service isProxy='false'>TestUpdateDB/BS/CompanyDBBS</ctx:service>
<ctx:operation>updateCompany</ctx:operation>
</ctx:route>

it works,

if I declare a variable $theBS = the xml above (WITHOUT USING QUOTES!)  and I use the variable in the Service field, it doesn't work. I have tried $theBS and data($theBS), always the same error.
Either I get

Error preparing message for dispatch

or

The TokenIterator does not correspond to a XmlObject value

Anyway as very well explained in Oracle Samples:

OSB supports two methods to perform dynamic Service invocation:
1. URI Override using Route Options
2. Dynamic Routing/Publish

check the example"Dynamic Service Invocation" here
http://www.oracle.com/technology/sample_code/products/osb/index.html
that is:
http://www.oracle.com/technology/sample_code/products/osb/samples/DYNAMIC-DISPATCH.zip


To make it work, I did it this way:

assign 'TestUpdateDB/BS/CompanyDBBS'  (with quotes) to variable theBS

and use this in the Dynamic Routing node:

<ctx:route>
<ctx:service isProxy='false'>{data($theBS)}</ctx:service>
<ctx:operation>updateCompany</ctx:operation>
</ctx:route>

(don't forget the {} )


Another alternative is to write an XQueryand use it in the Dynamic Routing service field:

(:: pragma bea:global-element-return element="ns0:route" location="../../CommonResources/XSD/DynamicRouting.xsd" ::)

declare namespace ns0 = "http://www.bea.com/wli/sb/context";
declare namespace xf = "http://tempuri.org/TestUpdateDB/XQuery/routeToDynamicService/";

declare function xf:routeToDynamicService($string1 as xs:string,
    $string2 as xs:string)
    as element(ns0:route) {
       
            { $string1 }
            { $string2 }
       

};

declare variable $string1 as xs:string external;
declare variable $string2 as xs:string external;

xf:routeToDynamicService($string1, $string2)

where string1 is the URI and string2 the operation

(I have unzipped all the XSDs from the jar provided by Oracle and put them in CommonResources/XSD)

1 comment:

Janne said...

Hi,

this works for me too:

1) assign full business service path to variable theBS = prjFoo/BS/bsvcFoo (WITHOUT quotes)
2) in Dynamic Routing use: ...{$theBS}...

Janne