soapUI is a nice little web services testing tool. While working with it, I came across many “gotcha” moments. Life would be perfect without “gotchas”, ain’t it? Apparently, we live in a real world which is not so perfect and we have to work around the problems at times and get ahead. Over period of time, I came across some problems in soapUI and figured out a solution / work-around to those problems. I thought it would be nice to document those as and when I come across those. So here I am documenting these in part 1. I say “part 1″ because I anticipate many more problems and work-arounds to these to come in the near future as soapUI matures through its releases.
[Please note: the tips listed below, may or may not apply to your particular case, as it is highly possible that a problem in one version of soapUI is fixed in the next. Nevertheless, it helps having a list of these at hand in case yours happens to be one of them and for some reason, you don't want to upgrade to the next release]
- I changed my SOAP Request as per new schema definition, Why do I still get “Schema Compliance” FAILED error?
soapUI, by default, locally caches wsdl and schema definitions. You can change this behavior in soapUI’s preferences. In any case, if the web service schema changes on server, you need to right click on a given Binding and click on “Update Definition”. This will pop up a window where you can give the exact address of the web service which you would test your Binding and all requests associated with this Binding with. Once you update definitions all your requests shall start working fine.
- When I click in error log area, soapUI hangs !
This was a known issue in soapUI 2.0.2. It probably is fixed in the releases afterwards. Best thing is do not click in error log trying to reach the exact location of error ( as you might be used to in your IDE ). Other alternative is to upgrade to newer release of soapUI.
- I am using xmlHolder object from groovyUtils. But xmlHolder.setNodeValue does not work! How do I set values on xml holder nodes?
I found this problem in soapUI 2.0.2 again. Here is a workaround, instead of using syntax
use following syntax
xmlHolder[“//ns:books/ns1:book/ns1:Id“] = “1234”;
- I am using built-in context variable ‘projectDir’ and it gives me NullPointerException when I run the project using command line tool ‘testrunner.sh’ !
It seems ‘projectDir’ variable does not work when running project at command line. You have to use following technique instead:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
//and then use
- I use soapUI on Mac. Somehow ‘CMD + C’ and ‘CMD + V’ does not work for copy and paste respectively!
This was the weirdest behavior I came across in soapUI. There is a workaround though. I think soapUI gets confused between usual windows ‘Ctrl’ key and Mac ‘Ctrl’ key. So try ‘CTRL + C’ and ‘CTRL + V’ instead of ‘CMD’ key. Also sometimes, you might have to do ‘Ctrl + C’ and then to paste you might need to use ‘CMD + V’. But you get the point, try ‘Ctrl’ and ‘CMD’ keys interchangeably and you will get the desired behavior depending on your objective at that time.
- I cannot refer to testRunner object in my groovy assertion. How do I access a test-case or step therein from my groovy assertion?
This was quite an interesting one. typically when you want to access a current test case you would use a syntax
this works perfectly fine in a plain groovy step or setup or tear down scripts. However, when you try referring to testRunner within a groovy assertion step, soapUI throws exception. The workaround to this is accessing testCase or test step via ‘context’ object. So you can use a syntax
depending on your need.
- I opened up ‘preferences’ and changed some property. Now all my requests are failing !
This was a bug in soapUI 2.5.1. What happens is the moment you open up ‘preferences’ and change anything. Doesn’t matter what it is that you changed, the ‘HTTP Version’ property under ‘Preferences > Http Settings Tab’, by default changes from 1.1 to 0.9. This makes all your SOAP requests fail. The workaround is open up ‘Preferences > Http Settings Tab’ and change ‘HTTP Version’ property to ‘1.1’ OR simply refrain from using 2.5.1 and go back to good old version of soapUI that was working for you :)
- soapUI inserts double xml ending tags in SOAP Requests!
If your xml schema has a sequence of elements where ‘either or’ condition exists, soapUI somehow creates a double set of ending tags for one of the elements. For example: say your schema accepts either element or under a node as shown below:
<person> <licenseNumber>12345678</licenseNumber> <!-- OR --> <memberNumber>LIB-333</memberNumber> </person>
When you try to create default SOAP Request that has ‘person’ element OR even if you double click on existing SOAP Request (that you might have crafted very carefully) having ‘person’ element in it, soapUI somehow inserts one more ending tag for ‘licenseNumber’ or ‘memberNumber’ depending on whichever you are using. So for example, soapUI changes xml element in your request to look like:
<licenseNumber>12345678</licenseNumber></licenseNumber> OR <memberNumber>LIB-333</memberNumber></memberNumber>
Naturally you are not aware that soapUI changed this element behind the scenes and you try to run this request and things just don’t appear to work the way they used to. The workaround to this problem is that do not double click on SOAP Request that you have already crafted carefully unless you really need to modify it. Of course, pay attention to elements that are ‘either or’ type in schema and you might need to manually adjust them if soapUI changes those behind the scenes. This was a very annoying bug in soapUI 2.0.2. However this has been fixed in soapUI 2.5 onwards. So your other alternative is to move to newer version of soapUI.
- How do I flash ‘alert’ type of UI message box within my groovy script execution?
Many of you might already know the answer to this but I thought of adding this to the list because I don’t think its documented. You can use ‘com.eviware.soapui.support.UISupport.showInfoMessage’ to flash an alert type of message to the user from a groovy script within soapUI. For example:
com.eviware.soapui.support.UISupport.showInfoMessage(‘Sorry, you cannot execute this script unless database properties are set.’);
- How do I pretty print xml programmatically within my groovy script in soapUI?
Many times you will need to capture request or a response or a part of it to an external file for a later review. You can do this within your groovy script in very many different ways that I perhaps cannot cover in this post. However, the xml string that you write to the file may not be ‘pretty’ formatted and indented. You can certainly make use of built-in soapUI object com.eviware.soapui.support.xml.XmlUtils to do this for you. For example, in your groovy script:
... def xmlUtils = new com.eviware.soapui.support.xml.XmlUtils() ... //Say 'str' is the xml string you want to 'pretty' print //Format xml for easier viewing def prettyString = xmlUtils.prettyPrintXml(str) //Now use 'prettyString' string to write to a file or any other use that you might have
In fact there are many more methods on XmlUtils object that you can make use of. Refer to soapUI javadocs in order to understand how XmlUtils can help you.
I guess that’s it for part 1. Hope that helps till I come up with part 2.