Forum Discussion
Hello
I have
1. A Data source with 3 columns (firstName, lastName) with a row of data
2. In one row the firstName is empty
3. I have a SOAP test with the Properties mapped
Now everytime the row with missing firstName is hit, it is introducing <firstName/> in the request XML (which can only be seen from Raw view) and the response fails (since there is a rule that any of these firstName, lastName should either do not have values or value of length 1 - 10).
So the Request XML I am expecting is
<customerSearchRequest xmlns="http://www.XYZ.net/services/customersearch">
<customerName>
<lastName>Langley</lastName>
</customerName>
</customerSearchRequest>
but it is taking
<customerSearchRequest xmlns="http://www.XYZ.net/services/customersearch">
<customerName>
<firstName></firstName>
<lastName>Langley</lastName>
</customerName>
</customerSearchRequest>
I followed the post and created a RequestFilter.filterRequest event and wrote the below code in the Edit section (I am using ReadyAPI)
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)
}
holder.updateProperty()
context.requestContent = holder.xml
But I am unable to remove <firstName></firstName> from the request. Where am I doing wrong?
Related Content
- 6 years ago
- 14 years ago