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 :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<slg:CustomHeader xmlns:slg="http://www.it.eye.nl/services/CustomHeader">
<slg:CorrelationId>3253252er5235432</slg:CorrelationId>
<slg:MessageType>iDOC</slg:MessageType>
<slg:TimeStamp>2001-12-17T09:30:47Z</slg:TimeStamp>
<slg:Status>OK</slg:Status>
<slg:Direction/>
</slg:CustomHeader>
</soap:Header>
<soap:Body>
<!-- over here the body payload -->
</soap:Body>
</soap:Envelope>
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.
- declare function xf:Header2EventObject($customHeader1 as element(ns1:CustomHeader))
- declare function xf:Header2EventObject($corId as xs:string, $MessageType as xs:string, $Status as xs:string)
- 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. - We only assign the values we need, but when the xquery results in an empty node the assign will fail.
<con:fault xmlns:con="http://www.bea.com/wli/sb/context"> <con:errorCode>BEA-382510</con:errorCode> <con:reason> 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 </con:reason> <con:location> <con:node>PipelinePairNode1</con:node> <con:pipeline>PipelinePairNode1_request</con:pipeline> <con:stage>stage1</con:stage> <con:path>request-pipeline</con:path> </con:location> </con:fault>
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
declare function xf:test1($corId as xs:string?,
$MessageType as xs:string?,
$Status as xs:string)
as element(ns0:EventObject) {
<ns0:EventObject>
<ns0:Logging>
<ns0:CorId>{ $corId }</ns0:CorId>
<ns0:MesType>{ $MessageType }</ns0:MesType>
<ns0:Status>{ $Status }</ns0:Status>
</ns0:Logging>
</ns0:EventObject>
};
See the definition of the $corId and $MessageType, now they can be null!
Popularity: 2% [?]



2 Responses to “Oracle Service Bus, xquery and optional parameters”
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…
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