'Mule http connector encoding

I am posting xml string use mule http connector to my client. The xml has string "Grubišić". It works fine if I post data to client from anypoint studio. If run on production or testing server, my client received "GrubiÅ¡iÄ" instead of "Grubišić". I tried to specify content-type = "application/xml;charset=UTF-8" from http request header, payload property.. none of them worked.

<set-payload value="#[flowVars.myXML]" encoding="UTF-8" mimeType="application/xml" doc:name="Set Payload"/>
<http:request config-ref="HTTP_Request_Configuration" path="/api/upload" method="POST" doc:name="HTTP" >
    <http:request-builder>
        <http:header headerName="Content-Type" value="application/xml;charset=UTF-8"/>
    </http:request-builder>
</http:request>

I am using 3.9CE runtime.

Am I missing any config? or it could be a bug in 39CE standalone? Thanks -Susan



Solution 1:[1]

There a lot of context missing in the question to be sure, but setting the encoding in the set-payload operation or in the Content-Type header doesn't actually transform the payload to or from UTF-8. A common mistake is to assume because the configurations, or even the XML declaration says UTF-8, to assume that the data is UTF-8 automatically. It is the data that is in UTF-8 or not. Most probably you are using a payload that is in a local encoding (Windows-1252 or something similar) when you test locally, but your server uses UTF-8 by default so it doesn't appear as you are expecting. "GrubiÅ¡iÄ" looks very similar to how the UTF-8 encoding of "Grubiši?" would look.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 aled