6 Replies Latest reply on Mar 25, 2008 11:32 AM by trouby

    communicating with WS in c# thorugh Java - encoding problem

    trouby

      Hey,

      I have a simple .NET ws based on WCF technology with some simple method which expect an object that has few string properties,


      I have created the relevant artifacts with wsimport and everything works as expected,

      The string property is encoded with UTF-8, for some reason, on the .NET ws side the strings are not getting decoded correctly. when I dump the strings I see gibberish,

      I'm not sure why but I was expecting a UTF-8 content on the WS side,


      The method calls to the WS are being invoked through Jboss EJB using the WS 2.0.3 package,


      Many thanks,

      Asaf.

        • 1. Re: communicating with WS in c# thorugh Java - encoding prob
          thomas.diesler

          javax.xml.soap.SOAPMessage

           /** Specifies the character type encoding for the SOAP Message. Valid values include "utf-8" and "utf-16". The default is "utf-8". */
           public static final String CHARACTER_SET_ENCODING = "javax.xml.soap.character-set-encoding";
          


          The soap message can either be UTF-8 or UTF-16 encoded

          We regularly attend the MSFT .NET interop workshop and don't see that issue there

          • 2. Re: communicating with WS in c# thorugh Java - encoding prob
            trouby

            Hey,

            Well, something is wrong,
            I have a file saved as unicode, I read the content of the file into a java String variable and pass it to the WS,

            I see gibberish on the other side (C#),


            Is there any way to investigate it? are there any WS testcases in C#/.NET and WS client code in java so I can take a look and see what's wrong ?


            I have an assumption that the content gets encoded more than once on the way for some reason,


            Many thanks,

            Asaf.

            • 3. Re: communicating with WS in c# thorugh Java - encoding prob
              trouby

              Hey,

              I performed some tests and now I am sure there's encoding problem but I'm not sure on which size,

              I've created the simplest WS .NET method with one string parameter and after calling the WS method, on the .NET side I see gibberish instead of UTF8 encoded string,


              Please note, English works fine, the problem occurs only in other languages (in my situation it's hebrew)


              Is there anything I can do?
              I'm clueless, I'm finding myself encoding/decoding strings in Base64 because of this issue :(



              Many thanks,

              Asaf.

              • 4. Re: communicating with WS in c# thorugh Java - encoding prob
                asoldano

                Well, you could start investigating what actually goes to the wire to understand which side is the problem. This way we could eventually see if there's an issue and perhaps create a test case showing it.

                • 5. Re: communicating with WS in c# thorugh Java - encoding prob
                  ronari21


                  Asaf,

                  We had the same problem. The problem occur because not all the steps that are involved in Web Services creation support UTF-8 by default.

                  Add to your JBoss startup script the following parameter: -Dfile.encoding=utf-8

                  This should solve your problem.

                  Ronen

                  • 6. Re: communicating with WS in c# thorugh Java - encoding prob
                    trouby

                    Great,

                    I wouldn't never imagine that this flag is related to WS encoding,


                    Many thanks,

                    Asaf.