williammary avatar image
williammary asked williammary posted

XML Response Mapping

I am having difficulty getting any type of XML Response mapping to work. The help says it should be as simple as indicating the response map as structured XML. The queries should the be filled in automatically. I get no queries at all after response mapping and XML response from a readfile of an xml document.


I dont even have grey boxes in the response even though the step has the check box set for autogenerated response maps. Is there a prerequisite that I am missing?

iTestresponse map
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

KumarS avatar image
KumarS answered KumarS posted

Response mapping is the process of taking "structured or unstructured data" and converting it to XML. Then Queries are used to extract data from this XML using XPATH.


So a XML response map simply is the process of doing nothing because it can be just copied over to the final data. 


Since XML data is going to be arbitrary, no queries will be automatically generated. No grey boxes or blue boxes will be drawn either. You will have to add your own queries to this response map. Response view in this mode is kind of useless because you are mainly going to view data as seen in the Structure View along with the queries you have defined (which can be seen in the Queries view). 

1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

PaulD avatar image PaulD commented ·

Let me add a bit of color to this.


Every response in iTest is kind of like a document you download via HTTP.  The response text itself has a content-type property that you don't normally see. But unlike HTTP, each response also contains an XML document that we call the "structured data" associated with the response.  The response has one more thing -- which are a set of pre-defined queries that you can apply to the structured data that return interesting data.  These queries fetch data from the structured data.  But they also check to see if that structured data is linked to a field within the textual response.  The "blue boxes" represent all of the fields in the textual response that are linked to results from pre-defined queries.


Most applications (like telnet, ssh, etc.) return a textual response and they set the content-type to "text".  But if the content-type is set to "text/xml", then our infrastructure automatically does the work of interpreting the textual response as an XML document and populates the structured data accordingly.  If the content-type is "text", but you know a priori that the content is XML, then you can create a response map to associate with the step, and configure it accordingly.  And that will do the same thing -- populate the structured data based on the textual content.


At the end of this, the point is that the structured data is not populated.  If you want to get information out of the structured data, you do that using queries.  An analysis "query" rule uses an XPATH query to extract data from the structured data in the response.  When you select a blue box in the response text and ask to perform a query on it, this is just short-hand for picking the XPATH query on the structured data that finds information that is linked to the text in that blue box.  

In the case of an XML response (with the appropriate content-type or response map), there are no blue boxes in the text.  But the structured data is populated.  If you open the "Structure" view that is what you will be seeing.  You can right-click there and perform analysis on it.


So you might ask, "In this case, why is the Queries view empty?  And why are there no blue boxes in the text?"  Good questions.  The Queries view is empty here because we can't know for an arbitrary XML document what kind of queries you might want to make on it.  That is, we can't really do any more for you than allowing you to enter your own XPATH queries.  So the Queries view -- which shows you the predefined queries is therefore empty.  You should use the Structure view instead.  As for the question of why there are no blue boxes, the answer is the same.  We don't know what to query for, so there are no blue boxes because there are no predefined queries.  There happens to also be one other more mundane reason.  That's because the library that we use to extract XML from text doesn't provide us the normal linking back of XPATH elements and attributes back to the position in the textual document from which they came.  Theoretically, this should be easy, but we haven't bothered to add that overlay logic -- because of the other points mentioned above.


One more point, if you add a response map for an XML response, you also have the opportunity to create your own predefined queries by using the ability in our response maps to define custom queries.  This still won't produce "blue boxes" for you.  But now the Queries view will have a pick list of items that anyone case use without being an XPATH expert.  This is our recommended approach for building up a strong framework around tools that produce XML output.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.