UPC_Broadband_L
12 years agoOccasional Contributor
Problems removing CDATA tags using Events
I currently have in place a REST service whose response returns a CDATA tag with xml contents. Reading some of your available guides, I tried to remove the tag so that soapUI Pro can handle the contents as regular XML (for proper XML formatting, etc).
I found two approaches using Events at the project level:
- SubmitListener.afterSubmit
def content = submit.response.responseContent
content = content.replaceAll( "<!\\[CDATA\\[", "" )
content = content.replaceAll( "]]>", "" )
log.info( content )
submit.response.responseContent = content
- RequestFilter.afterRequest
// get response content
def content = context.httpResponse.responseContent
// manipulate content
log.info( content )
content = content.replaceAll( "<!\\[CDATA\\[", "" )
content = content.replaceAll( "]]>", "" )
// write it back
context.httpResponse.responseContent = content
However, the response always arrives with the tag. If I make errors in the event scripts, there are errors being shown when executing any REST request on a Test Case, but I can never spot the execution itself or even the "log.info( content )".
Screenshots attached.
I found two approaches using Events at the project level:
- SubmitListener.afterSubmit
def content = submit.response.responseContent
content = content.replaceAll( "<!\\[CDATA\\[", "" )
content = content.replaceAll( "]]>", "" )
log.info( content )
submit.response.responseContent = content
- RequestFilter.afterRequest
// get response content
def content = context.httpResponse.responseContent
// manipulate content
log.info( content )
content = content.replaceAll( "<!\\[CDATA\\[", "" )
content = content.replaceAll( "]]>", "" )
// write it back
context.httpResponse.responseContent = content
However, the response always arrives with the tag. If I make errors in the event scripts, there are errors being shown when executing any REST request on a Test Case, but I can never spot the execution itself or even the "log.info( content )".
Screenshots attached.