Unable to find node for the given xpath expression.

I have a sequence which receives a form variable (via HTTP POST). I also set the payload of the sequence with a very simple XML document. I then use the set command to set the value a specific node, from the form variable I received. When doing this I get the following error:

com.softwareag.xbridge.exceptions.XException: Unable to find node for the given xpath expression. Xpath expression is : /m:GetInfoByZIP/m:USZip Line number : 10

The XML document used to set the payload of the sequence looks as follows:

<m:GetInfoByZIP xmlns:m=“http://www.webserviceX.NET”>
<m:USZip></m:USZip>
</m:GetInfoByZIP>

The XPath expression used to set the node looks like this:

/m:GetInfoByZIP/m:USZip

Which I verified both via XMLSpy and the XPath Tester tool in the Mediator GUI.

I’m attaching my sequence as well.

Any ideas what I’m doing wrong.

Theo
Get_Info_by_Zipcode_Sequence.xml (2.9 KB)

Hi Theo,

The problem is that you did not declare the namespace prefix somewhere in the sequence. You need to add
xmlns:m=“http://www.webserviceX.NET
to either the statement or one if its parents (like the ).

For Mediator xpath expressions to support namespaces, you need to be sure the namespace declaration is in the appropriate Mediator document (either sequence or emerger, as appropriate.)

Hope this helps.

Best regards,
Mike

Thanks Mike,

that did the trick. Now that I think about it, the solution makes a lot of sense. Is there any other way to set the namespaces to be used in a sequence (other than go to the XML view and adding it to the Sequence statement or the step where you plan to reference the namespace)?

If not, would it make sense to add this capability (in the form of a namespace set command)?

Thanks again for the help.

Regards
Theo

Hi Theo,

You can easily add namespace declarations by selecting the statement you wish to add it to, then right click on the Property Editor paned and choose “Add…”. The resulting dialog will allow you to add a namespace declaration. You do not need to enter the “xmlsn:” part, just the prefix.

Hope this helps.

Best regards,
Mike

Thanks Mike,

exactly what I wanted.

Theo