Ask a Question

[RE-OPENED]SoapUI Pro changing response of xml document within xml document

skillsoft
Frequent Contributor

[RE-OPENED]SoapUI Pro changing response of xml document within xml document

Is there an preference I can set or some other way to have it so SoapUI Pro is not modifying the response when it is interpreting the XML from the raw data? 

We have an API whos response returns an xml document within an xml document.  It looks like SoapUI is attempting to decode that XML and trying to represent a document within a document, which results in non well-formed XML which it puts CDATA tags around. This non well-formed XML ends up looking like this:


   
     
         <?xml version="1.0" encoding="UTF-8"?><SkillPort><BaseSite><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-09-29 17:34:38.68" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></BaseSite><AdvancedGroup Name="AGHapi" Orgcode="AGHapi"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-01 10:03:22.68" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup></SkillPort>
     

   


The raw data that is coming back looks like this (and is well-formed):

<?xml version="1.0" encoding="UTF-8"?><SkillPort><BaseSite><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-09-29 17:34:38.68" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></BaseSite><AdvancedGroup Name="AGHapi" Orgcode="AGHapi"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-01 10:03:22.68" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup></SkillPort>

Thanks,

Mary
40 REPLIES 40
skillsoft
Frequent Contributor

Hi,

That sounds like what I need.  If you could create an example for me, that would be great.  I'll give it a try and let you know how it works out.

Thanks,

Mary
skillsoft
Frequent Contributor

Hi,

Did you get a chance to create an example that I can try out?   

Thanks,

Mary
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi Mary,

sorry for the delay, I'm working on it right now.. can you (once again) show me the raw response returned by your server?

regards!

/ole
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
skillsoft
Frequent Contributor

Hi,

Here is the raw response for that same service:

<?xml version="1.0" encoding="UTF-8"?><SkillPort><BaseSite><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 15:05:54.583" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></BaseSite><AdvancedGroup Name="AGHapi" Orgcode="AGHapi"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 16:12:54.737" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup><AdvancedGroup Name="test" Orgcode="123456_-"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 18:42:57.857" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup></SkillPort>

Thanks,

Mary
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi Mary,

thank you.

Ok.. try adding a SubmitListener.afterSubmit handler to your project (in the Project/Events tab);

if( submit.response == null )
  return

def content = submit.response.responseContent
content = content.replaceAll( "<", "<" )
content = content.replaceAll( ">", ">" )

submit.response.responseContent =  content


This should change the response internally in soapUI so that the contained xml document is seen as xml and not as a string.

Tell me how it works!

regards,

/Ole
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
skillsoft
Frequent Contributor

Hi Ole,

I added the SubmitListener.afterSubmit handler.  I am still getting the CDATA tags after I submit the request.  Here is the response as it appears on the XML tab after the listener was added.



 
     
        <?xml version="1.0" encoding="UTF-8"?><SkillPort><BaseSite><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 15:05:54.583" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></BaseSite><AdvancedGroup Name="AGHapi" Orgcode="AGHapi"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 16:12:54.737" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup><AdvancedGroup Name="test" Orgcode="123456_-"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 18:42:57.857" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup></SkillPort>
     

 


Any other ideas?  What exactly needs to be removed/added?

Mary
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi Mary,

hmm.. please add

log.info content

at the end of the handler, which will write the content to the script log.. can you check what it is writing there?

regards,

/Ole
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
skillsoft
Frequent Contributor

Hi Ole,

This is what is writing to the script log after adding the log.info content:

Mon Oct 05 11:52:27 EDT 2009:INFO:
 
     
        <?xml version="1.0" encoding="UTF-8"?><SkillPort><BaseSite><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 15:05:54.583" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></BaseSite><AdvancedGroup Name="AGHapi" Orgcode="AGHapi"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 16:12:54.737" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup><AdvancedGroup Name="test" Orgcode="123456_-"><WebsiteColors CurrentColor="#FFFFFF" DefaultColor="#FFFFFF" ModifiedByServer="vmhapi" ModifiedByUser="-1" ModifiedDate="2009-10-02 18:42:57.857" Name="COLOR_LOGIN_DIALOG_BUTTON_TEXT"/></AdvancedGroup></SkillPort>
     

 
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi!

ah.. ok.. so try modifying the script to be:

if( submit.response == null )
  return

def content = submit.response.responseContent
content = content.replaceAll( "<", "<" )
content = content.replaceAll( ">", ">" )
content = content.replaceAll("<![CDATA[<\\?xml version=\"1\\.0\" encoding=\"UTF-8\"\\?>", "" )
content = content.replaceAll( "]]>", "" )

log.info content

submit.response.responseContent =  content


Now what happens?

Thanks for bearing with me..

/Ole
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
skillsoft
Frequent Contributor

Hi Ole,


I get this in my SoapUI log:

Mon Oct 05 12:08:16 EDT 2009:ERROR:java.util.regex.PatternSyntaxException: Illegal character range near index 45
<\?xml version="1\.0" encoding="UTF-8"\?><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^<br /><br />Thanks,<br /><br />Mary
cancel
Showing results for 
Search instead for 
Did you mean: