XML response encoding problem

Five Stars

XML response encoding problem

Hello, all,

I've created a job, that making request to external REST service, by request to this job, and returning body as the XML file. job.pngJobBut the response has a problem with encoding random chars inside a body.  Although, writing response content to file(in tHttpRequest _1) works fine.  Response from external REST service moves between components as String.through_job.png

 

I've already try add to "Advanced settings" parameter  "-Dfile.encoding=UTF-8", but it hasn't worked.

 

Anyone have an idea, why does it can work incorrectly?


Accepted Solutions
Five Stars

Re: XML response encoding problem

Thanks, all, for trying to help. The problem really places inside the tHttpRequest code. It reads a chunk of bytes from response stream, converts them into String and concatenates them. This algorithm works well if the response contains only ASCII symbols or response length less then 1024 byte(hardcoded size of the chunk). In other situations, it can split symbol. I've  moved creating String from bytes after reading the response and it's worked. I've attached my version of this component. The issue in bugtracker will be created later.


All Replies
Ten Stars

Re: XML response encoding problem

Did you set your Header correctly? Something like:
"Content-type" : "application/xml; charset=utf-8"
Five Stars

Re: XML response encoding problem

Yes. I added this header to tRESTResponse_1 component, response.png

 

but it hasn't worked too.

 

Ten Stars

Re: XML response encoding problem

Annoying... could it be that the data is extracted from different source(tables) which has a different collation setup (LATIN-1_general)? The other thing I could come up with is UTF-16?

Five Stars

Re: XML response encoding problem

External service returns correct XML. I guess, the problem appears inside components after tHttpRequest_1 or during moving between them.  I'll try to watch transformation this response in debugger.

Five Stars

Re: XML response encoding problem

Thanks, all, for trying to help. The problem really places inside the tHttpRequest code. It reads a chunk of bytes from response stream, converts them into String and concatenates them. This algorithm works well if the response contains only ASCII symbols or response length less then 1024 byte(hardcoded size of the chunk). In other situations, it can split symbol. I've  moved creating String from bytes after reading the response and it's worked. I've attached my version of this component. The issue in bugtracker will be created later.