Oracle Service Bus, xquery and optional parameters

We use custom soap headers to implement end-to-end tracking over all eai components.
Those headers will get updated during transport over all components and will also get logged to the db, together with some other metadata.
That info will be used to track and trace messages and problems.

A soap-envelope will look like this :
[sourcecode language=’xml’]




3253252er5235432
iDOC
2001-12-17T09:30:47Z
OK







[/sourcecode]

Some fields in the payload can be nullable.
When we create an xquery to transform this header to our EventObject-variable we can either create the xquery with one parameter which holds the whole ‘CustomHeader’ payload, or just map the parameters we need.

  1. declare function xf:Header2EventObject($customHeader1 as element(ns1:CustomHeader))
  2. declare function xf:Header2EventObject($corId as xs:string, $MessageType as xs:string, $Status as xs:string)
  1. When we use the payload described in the example, the assign will work. Only problem is we need to assign the whole CustomHeader-element as parameter.
    When we need to data out of the body-payload which could get huge, we would need to assign this whole payload just to get a few values out of it.
  2. We only assign the values we need, but when the xquery results in an empty node the assign will fail.
    [sourcecode language=’xml’]

    BEA-382510

    OSB Assign action failed updating variable “eventObject”: com.bea.wli.common.xquery.XQueryException: Error parsing XML: {err}FORG0005: expected exactly one item, got 0 items


    PipelinePairNode1
    PipelinePairNode1_request
    stage1
    request-pipeline


    [/sourcecode]

And the solution i was looking for (thanks to a colleague)
I need to be able to setup the parameters of the xquery as optional, like this i don’t need to evaluate every parameter in the xquery and can just pass the result of the xquery which is used for every parameter of the xquery.

http://www.w3.org/TR/xquery/
“attribute()? refers to an optional attribute node”

The xquery function will then look like
[sourcecode language=’java’]
declare function xf:test1($corId as xs:string?,
$MessageType as xs:string?,
$Status as xs:string)
as element(ns0:EventObject) {


{ $corId }
{ $MessageType }
{ $Status }


};
[/sourcecode]

See the definition of the $corId and $MessageType, now they can be null!

Original blog

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

2 Responses to “Oracle Service Bus, xquery and optional parameters”

commenter

Hey I’m starting to work with the OSB and I read all about it, but I’m still failing.

Could you please help me out on understanding what am I doing wrong…
This is the situation I created a XQuery transformation, but I’m pretending to transform the whole $body variable.
So I created *.xq file, and I tested only with the XML that I want to transform, and it works just fine.

When I’m trying to add it to my proxy flow, I got the error
BEA-382510

ALSB Assign action failed updating variable
And says that I’m doing an ArrayOutOfBound Exception.

I just don’t get why this is happening…

Could you please help me out on understanding the deep reason for this?

Thanks in advance, do you think we could keep in touch by msn messenger?
Mine is rekiem_angel@hotmail.com please do not hesitate on add me and start chatting.

Once again thanks in advance and best regards!!

Mike
Hope to hear soon from you…

commenter

Hi Mike,

Can you email me the whole stacktrace, an example xml and the xquery your creating?
You can send it to eric dot elzinga @ it-eye.nl

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>