How to send null values in soapUI requests

Saturday, May 16th 2009, 00:58

soapUI is a pretty useful web service testing tool that can help you generate a multitude of tests like load testing, functional testing, data consistency testing and many more. I have started using it for real two days ago when I needed to test some SOAP web services for work. The main issue that kept me from being more productive with this test platform was that nowhere in its documentation one can find how to send null values in a request.

In the soapUI User Guide, in the “Working with Web Service Request” there is a tricky property called Remove Empty Content.

Remove Empty Content : Removes empty elements/attributes from outgoing requests. This can be useful in Data Drive TestRequests which contain elements/attributes that not always contain data and should be removed in those cases.

What I understand from this property is that if I have an empty field that I would like not to be transmitted further into my request, setting this property to true, the field will be marked as null and transmitted like that. Well, the result isn’t the one you would have expected. Doing like that will only bring you more and more frustrations as the only thing you will obtain will be a beautifully crafted server error complaining that some fields don’t have proper values (the errors are more technical like “invalid date format or argument“, “value expected for … field“).

So, answering the question “How to send null data in a request with soapUI?“, the thing that you should do is to mark the respective field like this:

<ns :field xmlns:field="http://www.w3.org/2001/XMLSchema-instance" field:nil="true" />

or, assuming that you do not want to write this kind of attributes for many empty fields in a request, something like this:

<?xml version="1.0" encoding="utf-8"?>
<soap :Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapbody>
    <parenttag>
        <childtag1>value</childtag1>
        <childtag2 xsi:nil="true" />
        <childtag2 xsi:nil="true" />
    </parenttag>
</soapbody>
</soap>

Enjoy!

Similar Posts:

1 Comment

  • Thank you for your post I really liked it:)
    We will link to your blog from our website

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


CODE EXAMPLES: When you want to include source code or terminal output, please use the the following tags like in the next example:

    [language]
    code lines
    [/language]
	

where you substitute language with the programming laguage used throught the code example (for terminal output that would be bash), e.g:

    [bash]
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    [/bash]
	

To see a list of all the supported languages, please check this page.

If you want to include code bits inline, please use the code tags like in the following example:

    The <code>$USER</code> variable holds the current logged in username.
	

Secure your files

Dropbox

Recent Comments

  • Radu said:
    After you install VMware Server there is no menu entry for it. To access its interface you should open a browser tab and go to... more»
  • Radu said:
    I bought mine just a month before they launched the 3rd generation. But it’s really okay for my needs. more»
  • Radu said:
    Something must have gone wrong during the install process. Try to reinstall the drivers (after you have uninstalled them previously)... more»
  • Radu said:
    I think you should start Firefox (due to the fact that the plugin runs under it) with that custom wrapper script. more»
  • RGG said:
    As with Mai I removed vmnet, vmci and vmmon. Ran sudo vmware-config.pl and it reran the last part of the install but did not add any... more»

Recent Tweets

Geek blogs

Bear