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
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi!

ok.. next try replacing

content = content.replaceAll("<\\?xml version=\"1\\.0\" encoding=\"UTF-8\"\\?>", "" )<br /><br />with<br /><br />content = content.replaceAll("<!\\[CDATA\\[<\\?xml version=\"1\\.0\" encoding=\"UTF-8\"\\?>", "" )<br /><br />where does that take us?<br /><br />(I'm trying to the regular expression right that removes the specified string from the message..)<br /><br />regards!<br /><br />/Ole<br />eviware.com

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

Hi Ole,

That worked!!!  Thank you so much!!  You just made my life a lot easier.  I can verify the XML is valid some other way...but to verify the contents....it's seeing the different elements and attributes on the outline tab and I can do property transfers, wildcarding, etc. 

This is what I ended up with (tried a different web service):


 
     
       
     

 



Thanks,

Mary
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi,

finally! Hopefully this works for all the services you are going to test.. otherwise just post again and we'll try to figure it out some more..

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,

The assertions that I create from the responses after this listener is applied are passing when they are created, but failing when I run them.  have tried XPath Matches, existence with script, RegExp.  It seems that is changing the response after the assertions are run.  A typical error that I'm getting in the assertion:

XPathContains assertion failed for path [declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
//soapenv:Envelope[1]] : Exception:org.custommonkey.xmlunit.Diff
[different] Expected number of child nodes '3' but was '1' - comparing at /Envelope[1]/Body[1]/getSearchParamsResponse[1]/return[1] to at /Envelope[1]/Body[1]/getSearchParamsResponse[1]/return[1]

I've tried doing a script assertion and inserting a 10 second delay, but it didn't help.  The weird thing is, when I create a new assertion, any previous assertions I have on that request appear to pass.  I looked at the other listeners and tried a few, but no luck.


I am running into another issue as well, that I can't blindly change all the <> globally as some of the web service responses have these tags in attributes.  I think I can figure out the that issue, but the first one is a show stopper.

Thanks,

Mary
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi Mary,

at what level are you running your tests when this happens? Project/TestSuite/TestCase/Request?

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 was running just the request. Sorry, I just assumed it would always fail. When I run the testcase, testsuite and project it passes just fine.  Why does it fail when I run the request?  Just curious.  I can live with that.

Now to figure out the rest of the issues, which I can figure out.  I need to get more familiar with groovy scripting anyway....

Thanks,

Mary
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi!

hmm... do you have pretty printing turned on or off for this request?

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 have pretty printing turned on globally.  You can turn it on and off at the request level?  I looked around and I can't see where you would do that.

Thanks,

Mary
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi Mary,

In TestRequest Properties panel (down on the left when you select TestRequest) there is a PrityPrint property which can be set to true or false.

Regards,

/Dragica
eviware.com

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

Hi Dragica,

Thanks, I found it.  It was set to true on the request.  I changed it to false and it doesn't make any difference.  My XPath Match still fails with the same error.  If I run the testcase, suite or project, that same request will pass.  Not a big deal, and we can work around it.  Just wondering why, that's all.

Thanks,

Mary
cancel
Showing results for 
Search instead for 
Did you mean: