0

I am integrating third party API using Rest Template, which will send the response in the format of XML. But for some of the request, getting the below error.

Could not unmarshal to [class com.xxx.SearchResponse]: null; nested exception is javax.xml.bind.UnmarshalException\n - with linked exception:\n[com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

I tried with contentType as "application/xml", "text/plain", "text/xml" , "text/xml,charset=UTF-8"

Only for some of the response, getting this error and also xml response has too many lines. Hard to detect the characters facing this problem. I guess some content type i am missing it.

XML Element:

<search-response xmlns="" xmlns:info="" xmlns:common="">
<search-response>

When i hit the third party API in the postman, getting the content type as "text/xml;charset=ISO-8859-1"

Premanand K
  • 632
  • 8
  • 18
  • A `MalformedByteSequenceException` means the server does not send UTF8. Post the (filtered) response somewhere we can see it – Raffaele Jul 25 '17 at 14:49
  • Service is sending ISO-8859-1, you are treating as UTF-8. That's all there is to it. You need to read respect the content type you saw in postman. – bmargulies Jul 25 '17 at 15:03
  • I tried to set like ""Content-Type", "text/xml;charset=ISO-8859-1", still getting the same error. – Premanand K Jul 25 '17 at 15:15

0 Answers0