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:service isProxy='false'>TestUpdateDB/BS/CompanyDBBS</ctx:service>

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


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
that is:

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:service isProxy='false'>{data($theBS)}</ctx:service>

(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 = "";
declare namespace xf = "";

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...


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}...