Skip to main content

J2ME web services(JSR 172): how to specify default character encoding?

4 replies [Last post]
Joined: 2010-01-16

Hi guys,

how can I specify the default (or custom) character encoding when using the WSA (JSR 172) ?

I have a problem with non-english characters. When I invoke a generated Stub it doesn't negotiate the character encoding when obtaining the handshake with a Web-Service. The Web-Service then sends a default charset="iso-8859-1" encoding. Then when the WS-Client sends some request it is encoded in utf-8. The WS-Service returns a response encoded in iso-8859-1.... All the special characters get screwed up! (and I even get exceptions sometimes...) :(

P.S. I've figured all that by using wireshark to debug the sent SOAP Messages on the fly.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2010-01-16

I have resolved the problem by myself since no one jumped in and did my programming for me :P

Joined: 2010-05-19

I'm facing exactly the same problem.
Have you found a solution?

I'm working with the JSR 172 on a java blackberry project.


Joined: 2010-01-16

Hi there,

well yes and no :)

I was unable to fix the problem since the underlying communication is hardcoded (aka Operation class that is invoked from within the generated Stubs)...

Very BAD design what can I say...

But I've solved the problem for my project. I just reinvented the wheel and have written my own SOAP library. It is 33 KB and that includes all the logic - stubs + connection logic+ XML parsing+XML Composing. In comparison to the 600KB for the generated stubs from the Sun WTK's wsimport utility my library is a lighty bastard so to say :)

So my advice to you:

Option 1)
use some SOAP client/server testing tool (or wireshark if you wish) and see what SOAP XML messages the Java ME WSA actually sends & receives - then write your own library - it isn't as hard as it sounds - trust me.

Option 2) Use some third-party library like kSOAP2 (has also Android version)

Good luck with your project!


Joined: 2010-01-16

bump ? :)