Overview

Using XPath to retrieve webservice data

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.

//ws:GetCityWeatherByZIPResponse/ws:GetCityWeatherByZIPResult/ws:State

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

-Anish

Download: Demo Handler

Anish Sharma

Anish Sharma

I joined Interactive Intelligence in July, 2011. Prior to that, I worked with an Elite partner for 11 years. Over the years, I worked with various products from Interactive Intelligence, including support, implementation and development. A self-confessed geek, I enjoy taking things apart and figuring how it works. One of my passions is photography and I have a personal photo blog.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>