cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP-UI Mock: Response in different character sets on different systems - WHY?

Highlighted
Frequent Contributor

SOAP-UI Mock: Response in different character sets on different systems - WHY?

I have the odd case that a mock service that I defined works as intended on one system but not on another (both are Windows 10 workstations/laptops running the same version, configured with the same system language and character set and running the same Java version (AdoptOpenJDK v8.x)). On one system the payload is returned in the character set intended (UTF-16LE), on another the response is in a different character set (ISO-8891-5). Any explanation for that?

 

Background:

I need to create a REST-service mock that returns its response in an unusual character set: UTF-16LE.

 

For that I created a text-file (the name of the file is passed via a custom property) with the bitwise exact content of the intended response (i.e. saved in UTF-16LE) and I defined a scripted mock-response that reads the content of that file and returns it like so:

 

def path = context.expand('${#MockService#responseFileName}').trim()
log.info("reading data from '${path}'")
def file = new File(path)
if (file.exists() && file.isFile()) {
	byte[] fileBytes = file.bytes
	int length = fileBytes.length
	log.info("read ${length} bytes of data: '${fileBytes}'")

	String str =  new String(fileBytes, java.nio.charset.StandardCharsets.UTF_16LE)
	 mockResponse.responseContent = str
} else {
	throw new Exception("file '${path}' not found!")
}

 

 

The "Content | Media type:" defined in the response form is "text/csv; charset=UTF-16LE".

 

If I run that mock on my own laptop then the response I get from this service is EXACTLY as contained in the original file (i.e. in characters set of the response is signaled in the response header (as received by the browser and checked using FF's Web Developer tools) as "UTF-16LE" - as intended - and when saving the content to a file and comparing it to the original it is bitwise identical). This is as it should be!

 

But when the very same mock (i.e. same SOAP-UI project file and the very same input file (verified!)) runs on a colleague's laptop, then the character set signaled in the response header is "text/csv; charset=ISO-8859-1" (i.e. the header specified in the response form seems to be ignored)/overruled - why and by what?) and the content is indeed in ISO-8859-1 character set (aka. "ANSI"), i.e. different from my own laptop.

 

We are completely puzzled! Why does SOAP-UI behave so differently on two different systems? We faithfully checked all settings and preferences but we could not locate any differences. What can interfere here? What configuration controls this?

4 REPLIES 4
Highlighted
Community Hero

Re: SOAP-UI Mock: Response in different character sets on different systems - WHY?

Hey,

You mightve already confirmed this so apologies if you hVe, but have you compared the system properties of both instances?

I.e. Help >> System Properties

Id compare these. I know theres an emcoding/charset attribute in there somewhere that might help....

Cheers

Rich
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 Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Frequent Contributor

Re: SOAP-UI Mock: Response in different character sets on different systems - WHY?

We compared our System Properties. The only - in this context - possibly relevant difference is the file.encoding setting (UTF-8 in my case and Cp1252 on my colleague's machine). But the READING from file is not the issue here. The bytes read are identical (the script displays them in the log output - see line

log.info("read ${length} bytes of data: '${fileBytes}'"

... and at that point the bytes are exactly identical (i.e. identical values and correct byte ordering (according to UTF-16LE)).

 

It must be something that affects the SENDING of the response content and thereby mangling the character encoding.

Highlighted
Community Hero

Re: SOAP-UI Mock: Response in different character sets on different systems - WHY?

Hey @mmoser18,

I appreciate what you stated about something altering the sending of a response however a colleague had an issue that was analgous to yours, hence why i queried the default encoding.

When you say it runs differently on two machines, how were the readyapi! projects setup on each machine? Created in one, then a copy sent to the other machine? If thats not the case then the mocks were setup independently? If yes.......

To attempt to fix: export the project that works and import overwriting the project on the machine that doesnt work.
If this doesnt resolve the issue, then logically the issue is not at project level, its global/workspace level and id look at the differences in system properties as surely its reasonable that this could be the cause of the issue? Unless youve got a dodgy event handler running...

Ta

Rich
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 Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Frequent Contributor

Re: SOAP-UI Mock: Response in different character sets on different systems - WHY?

The project was carried over (via the same git-repo) and are identical.

SOAP-UI was installed on both systems using the vanilla installer.

No event handlers or other hooks were added.

 

I fail to see how any system settings could interfere here since the handling of the response is entirely done inside SOAP-UI. It reads the file (at which point the data are correct) and then converts the response to the response's payload and serves that via the built-in mockserver. So, "something" must be telling SOAP-UI to convert (or keep) the payload-string to/in UTF-16LE on my machine and to convert it ISO-8859-1 along the way on my colleague's system.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors