I am trying to send xml data through soapHTTP to a webservice .When i send the data the swedish characters in it are converted into some sort of invalid symbols which causes the webservice to fail.
Can anybody suggest me how should I process the soapMessage that the characters are transmitted correctly and is not rejected by the webervice.
i worked in sweden and had a lot of ‘fun’ with swedish special characters, i can tell you
ok, at first check in which encoding they come in the input xml, and just out of curiosity, try to do stringToBytes followed by bytesToString with the same encoding given.
You will see whether the resulting string will have the special characters intact or scrambled.
If they are ok, you know which encoding to use to convert them into the soapMessage.
Furthermore, sometimes direct converting from string to stream causes problems with special characters, as the IS built-in services use JVM default encoding (setup in the JVM config file), because they dont allow you to set the encoding yourself.
Try stringToStream and back streamToString to verify.
And this is what might be a problem, when building the soapMessage.
Secondly, try to capture the data as it is sent out from the IS to the web service with a tool like TcpTrace.
There you should be able to check the encoding and how the characters look like.
I once had to use a workaround and instead of sending the data as xml string and content type text/xml, I used content type quoted-printable or sent the data as base64 encoded.
Thirdly, if the data is sent out ok, then the receiving web service decoded them wrongly, which could be given with wrong encoding set for the content part or simply wrong encoding used in the flow.
As a last resort, you might have to write your own java services to convert string data from one encoding to another…
Hope this helps
It would be really help full if you could please let me know how to set the locale to european/swedish.Is it possible to set the locale for a particualar webservice instead at the intgeration server level.
I don’t think changing locale will fix the problem, since you are still processing xml with java. JVM will use the default encoding of the OS as the default if you don’t specify it.
You can try to save the original bytes to a file (without converting it to string) directly, try to open it with IE or xml tool (xmlspy). if the character shown is correct, that means the original is encoded properly. Now you also know it encoding (in the xml tag)
I’d suggest you to convert the string into UTF-8 (since it supports all launguages) before put it into your WS. ( you need to write a little java code to convert, also remember to chagne the encoding in xml tag.