This is going to be a short post as we wrap up our discussion from our last post. Let’s visit our response message and see how we can tackle the XPath issue where the prefix has not been assigned to our namespace in the response message.
One of the ways we can make this work is by defining a prefix of our choosing in our name space definition.
The step that is responsible for that is the ‘XML Set Document Property’ which allows you to define your namespaces.
The format used for defining the namespaces is as follows: xmlns:<prefix>=”<namespace-uri>”.The list needs to be white space separated and in our example, we will end up with a string as per below:
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ws="http://ws.cdyne.com/WeatherWS/"
Notice the prefix ‘ws’ assigned to the ‘http://ws.cdyne.com/WeatherWS’ namespace. That is our custom prefix so that now when we call our XPath statement, the statement would be valid and will be able to return some data. Our XPath statement needs to be revised as well so that it is pointing to the correct location.
Adding the above statement in our ‘XML Select Single Node’ will give us the value we need. After we are done with adding all the necessary steps, our handler should look something along:
While my demo handler is not really production ready, I have attached it at the end of this post so that you can have a play with it. As usual let me know if you have questions regarding what we discussed in this post.
Until next time, have a good day
Download: Demo Handler