Forum Discussion
5 Replies
Sort By
- omatzuraSuper ContributorHi!
sorry for the lack of documentation on this. There have been a couple of posts on this both here and on the sourceforge forums (http://sourceforge.net/forum/forum.php?forum_id=494205), please search around to find examples. Also, the documentation at http://www.soapui.org/userguide/mock/op ... ispatching and the included sample project has some code for this..
If this doesn't help, please ask more specific questions and I'll try to help you forward!
regards,
/Ole
eviware.com - richard_mccarthContributorHi Ole,
Thanks for your reply. I dug around and managed to figure out the basic formats for XPath and script as shown below.
XPath
--------
Return the data of the FromCurrency element in the 'web' namespace in the request, this needs to match a response name configured for the request.
e.g. if the from currency is USD then you need a response called USD
declare namespace web='http://www.webserviceX.NET/';
//web:FromCurrency/text()
Note where the return does not match a response name then you get the default response.
Script
-------
Using the same idea as above but with a script instead
def groovyUtils = new com.eviware.soapui.support.GroovyUtils (context)
def holder = groovyUtils.getXmlHolder ( mockRequest.requestContent )
def fromCcy = holder.getNodeValue("//web:FromCurrency/text()")
return fromCcy
Note it appears that where the return does not match a response name then you do not get the default response. - omatzuraSuper ContributorHi!
thanks! I've fixed the issue where the default response it not returned in case of a missing name returned by a dispatch script..
We really want to improve on the xpath version, which should basically allow you to select a target xpath expression and then configure which response to return based on the result (and not require the result to contain the name of the mockresponse)..
any other ideas for improvements are always welcome!
regards,
/Ole
eviware.com - richard_mccarthContributorHi Ole,
You are welcome. I was'nt sure if I had it right or not about the default response. The change to the XPath logic would be great as its a bit limited as it is,
Richard - Sachin_SaweContributorI found using groovy's native xml processing abilities much more faster and flexible in whatever you want to achieve while parsing response and generating request from the response. It is also easier than using xmlHolder. I had difficulties using xmlHolder where I need to pull node from response and add to next request. I simply could not do it. Plus add more confusion with namespaces for response being inconsistent with those for the request that you want to create. Using groovy you can totally define namespaces for generated request and even for each gpathresult
hope this helps
Sachin
Related Content
- 9 months agolodecesa
- 8 months agoMehwishDaud
Recent Discussions
- 59 minutes agoruchisingh