To be able to make use of Dynamic Xquery the xqueries itself all need to have the same defined interface.
So after defining the different xqueries and test them one by one in Eclipse all seem to work.
On runtime i get the next error :
[sourcecode language=”xml”]
The number of parameters for registered XQuery resource System1_To_Fault does not match that given to it at runtime
[/sourcecode]
I was pretty sure after logging all the binded input variables they were all containing data.
Lesson learned : Make sure you both bind all the variables but also ‘use’ them in the xquery itself.
OSB will return this fault either when you don’t bind all the variables but also if you don’t use all of them in the xquery
xquery1 fragment (will work):
[sourcecode language=”xml”]
xquery version “1.0” encoding “Cp1252”;
declare function xf:System1_To_Fault(
$metadata1 as xs:string,
$metadata2 as xs:string,
$metadata3 as xs:string)
as element(soapenv:Fault) {
};
declare variable $metadata1 as xs:string external;
declare variable $metadata2 as xs:string external;
declare variable $metadata3 as xs:string external;
xf:System1_To_Fault($metadata1, $metadata2, $metadata3)
[/sourcecode]
xquery2 fragment (will fail):
[sourcecode language=”xml”]
[/sourcecode]
inputvariable ‘metadata3’ isn’t used in the xquery itself, so the dynamix xquery will fail on runtime
either make sure you always use all the input variables in the xquery (or do an expression on it, for example assign it to an temp variable but don’t use it for generating your target xml)
something like this
[sourcecode language=”xml”]
let $temp := $metadata3
return
[/sourcecode]
I’m not sure what this assign will do (performance-wise) when you assign a big dom-tree variable, in that case you could just assign the deepest childnode to the temp variable.
Eventually it’s just a dirty fix to be able to use the xqueries in combination with dynamic xquery and still be able to not use all of the incoming parameters.
4 Responses to “Oracle Service Bus, The number of parameters for registered XQuery resource System1_To_Fault does not match that given to it at runtime”
I found that “mearly” referencing the input parameter in a variable was not enough.
I ended up with actually referencing the input parameter inside my response, e.g.
(: Dirty fix :)
{
if ($metadata3)
then ()
else ()
}
soapenv:Server
some description
some string to the resource
{$metadata1}
{$metadata2}
Hi Orjan!
This indeed got slightly changed in some new release of the osb. Before myfix worked, at my current client were also using some sort of fix like yours. Thanks for mentioning it in here!
[…] http://www.xenta.nl/blog/2011/10/19/oracle-service-bus-the-number-of-parameters-for-registered-xquer… […]
Thanks a lot for this help. This resolved the same issues I was facing.