cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid xml as special character in request body

SOLVED
Contributor

Invalid xml as special character in request body

Hi Community,

 

I encountered a special character issue with my REST POST payload (request body). As request, the payload include other characters, like Simplified (测试) / Traditional(測試) Chinese. after save project, the test case will be missing due to invalid xml. I open it with XML Spy and said there are invalid characters (acutally it's mass code becoz of special characters). If I accept XML spy convertion, then this xml would be imported into ReadyAPI.

I search the same issue from forum, but seems did not find a solution. Checked the encoding, it's UTF-8 in header of xml.

Content-type of my payload is application/json, appreciated if anyone who would provide available solution for that.

 

Thanks,

/Aaron

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Hero

Re: Invalid xml as special character in request body

In the ReadyAPI, what does it show when you click "Help -> System Properties" and "file.encoding"?

Set it "UTF-8"


Regards,
Rao.
Contributor

Re: Invalid xml as special character in request body

it's working after added -Dfile.encoding=UTF-8 in readyapi.vmoptions file. the chanage would be seen from Help -> System properties.

Thanks @nmrao@richie

7 REPLIES 7
Community Hero

Re: Invalid xml as special character in request body

In the ReadyAPI, what does it show when you click "Help -> System Properties" and "file.encoding"?

Set it "UTF-8"


Regards,
Rao.
Community Hero

Re: Invalid xml as special character in request body

Community Hero

Re: Invalid xml as special character in request body

Hi @aaronpliu

 

I had a similar problem with the ISO-8859-1 charset.  My testdata file included chars that weren't included within the UTR-8 charset - meaning that the project.xml file was no longer wellformed relative to the defined character set, meaning that the project.xml file couldn't be opened in REadyAPI! as ReadyAPI! requires the project.xml file to be wellformed....well - if you read certain literature - it states that XML isn't even XML until its wellformed! 

 

anway - to 'fix' it I had to open the malformed .xml file within an app that didnt include an XML parser (something like notepad++) and then replace the substitution characters with a char that was contained within both ISO-8859-1 and  UTF-8.  When I tried using XMLSpy (app that contains an XML parser) I couldn't alter the substitution characters - hence the reason I had to use an app without an XML parser.

#

I had a quick look at I've found contradictory info as to whether UTF-8 supports chinese characters - but it appears UTF-16 and UTF-32 does, so to ensure this doesnt occur again - you could always adopt the approach @nmrao suggested and update your file.encoding attribute in ReadyAPI!'s system properties from whatever it is (displayed in the system properties, file.encoding attribute value) but rather than change to UTF-8 - change to UTF-16 or 32 instead?

 

oh - one thing - UTF-8 is the default char encoding within .xml.  you can set it to other charsets - its just UTF-8 is the default one.

 

 grabbed the following from stackoverflow

Changing the default encoding
  1. Go to SOAPUI_HOME/bin.
  2. Open soapui.bat/.sh, depending on your platform.
  3. You should be able find JAVA_OPTS , then you can add there below line in a new line set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding="iso-8859-1" on windows. ...
  4. Save the file, start SoapUI .

 

Ok - this is a bit weird - my system properties 'file.encoding' attribute value is set as 'Cp1252'.  HOWEVER - if I look in the ready-api.bat file - the encoding value is set as 'iso-8859-1'

 

Confused.....I would expect them to be identical! 

 

Cheers,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Contributor

Re: Invalid xml as special character in request body

Thanks @nmrao @richie

I will try the solution and give your a feedback by then. Thank you very much

 

Thanks,

/Aaron

Contributor

Re: Invalid xml as special character in request body

it's working after added -Dfile.encoding=UTF-8 in readyapi.vmoptions file. the chanage would be seen from Help -> System properties.

Thanks @nmrao@richie

Community Hero

Re: Invalid xml as special character in request body

yay!  all good then fella! Smiley Happy

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Community Hero

Re: Invalid xml as special character in request body

SO post is mine too Smiley Wink


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win