I have defined a Proxy Service on my WSO2 ESB that transforms incoming messages using XQuery (I am following Sample 390).
The problem is that the ESB transforms the variable payload, which is defined as ELEMENT, into an XQuery vairable defined as document-node(). But, my XQuery accepts only element() :
declare variable $payload as element(ns:payload) external;
Is there any way howto define the ESB variable or modify the variable expression so that the input into the XQuery is element?
I tried :
<xquery key="xquery-key-req">
<variable xmlns:nms="http://my.nms.com" name="payload" expression="$body/nms:payload" type="ELEMENT" />
</xquery>
But this returns the following error:
Required item type of first argument of xf:xqueryRequest() is element({http://my.nms.com}payload); supplied value has item type document-node(element({http://my.nms.com}payload))
Well, you either have to change your query to expect a document node, or you have to change the client of the query to supply an element. I don’t know ESB so I don’t know how to make the change there, but changing the query is easy enough: