Forum Discussion

joakimrosendahl's avatar
joakimrosendahl
New Contributor
14 years ago

Remove Empty Content

Hi,

I almost found the perfect solution to a problem I am facing, but I don't know if you regard this as a bug or as a new feature. It seems like the feature "Remove Empty Conent" only processes the request once, but I was hoping it to do multiple passes. Removing all empty tags can result with an empty tag =). Example: Removing empty content in this pseudo-xml:

<tag1>
<prop1/>
<prop2></prop2>
</tag1>

The result from this is an tag with empty content:

<tag1/>


Regards,
Joakim.
  • Where do you see the feature "Remove Empty Content"?

    What is the behavior you are expecting?
  • This is a property of the Soap request (see properties grid for a soap request on the left bottom).

    I have exactly the same problem. I need an array that does not have any real content in it, to be an actual empty array, not an array with empty elements if all attributes of the elements are empty.

    Because this might hurt performance, it could be an extra setting "Remove Empty Content recursively", so that empty content is removed until no empty tags exist in the raw request only when this setting is true.
  • Joakim - Your old request from 28 feb 11 (See below) ... did you ever found a proper solution ... struggeling with EXACT same issue .... All Inner tags are cleared (Simply NO text) sas wanted - but the outer tag is left and with in the tag is a number of CR/LF charecters left - subsequently the service I call throws an error because IF the tag start/tag end is send the Schema checks for the content with in the Grup tag start/tag end .... frustrating ... ;-)

    Regrards Lars


    Remove Empty Content
    by joakimrosendahl » 28 Feb 2011 13:20

    Hi,

    I almost found the perfect solution to a problem I am facing, but I don't know if you regard this as a bug or as a new feature. It seems like the feature "Remove Empty Conent" only processes the request once, but I was hoping it to do multiple passes. Removing all empty tags can result with an empty tag =). Example: Removing empty content in this pseudo-xml:

    <tag1>
    <prop1/>
    <prop2></prop2>
    </tag1>

    The result from this is an tag with empty content:

    <tag1/>


    Regards,
    Joakim.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    This is in our backlog [SOAPUI-4059].


    Regards

    Henrik O
    SmartBear Software
  • isanals's avatar
    isanals
    New Contributor
    Hello!

    I've just started testing with SoapUI and I have exactly the same problem to remove the empty content... I see it is in the "backlog SOAPUI-4059".
    I use SoapUI Pro 4.6.0. and what I've read about 4.6.1 and 4.6.2, it is not implemented, isn't it? Please, has somebody found another way to solve it (Groovy, etc)? Or is there "combination of tools" in 4.6.1 or 4.6.2, that would help?

    Regards
    Isana
  • isanals's avatar
    isanals
    New Contributor
    Hello Markus

    Thank you for your feedback. But it doesnt work. What am I doing wrong?
    I created an event RequestFilter.filterRequest and in "Target" I put the script you have mentioned:

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def stepName = context.getCurrentStep().getLabel()
    def holder = groovyUtils.getXmlHolder( stepName + "#Request" )
    for( item in holder.getDomNodes( "//*[. = '']" )){
    holder.removeDomNodes("//"+item.nodeName)
    }
    // update request
    holder.updateProperty()
    // write updated request back to teststep
    context.requestContent = holder.xml

    Now the data from my xls are not read anymore from the Datasource. The request ist sent with the syntax the parameters as a string value. For example:
    <callContext>
    <caller>${DataSource_P#caller}</caller>
    <user>${DataSource_P#user}</user>
    <uuid>${DataSource_P#uuid}</uuid>
    </callContext>

    instead of:
    <callContext>
    <caller>T1</caller>
    <user>hausi</user>
    <uuid>uuidT1_1</uuid>
    </callContext>

    regards,
    Isana