5 Replies Latest reply: Jan 8, 2008 9:16 AM by Frank Heldt RSS

    charset problem with jbossws 2.0.2 and .net clients

    Ever Last Newbie

      Good evening ladies and gentleman,

      I am struggling sending special character like the German üö from the .net client to the jboss server.

      I have the following reproducible scenario:

      jboss 4.22
      jbossws 2.0.2GA
      .Net Client

      .net is pinging the following String to jboss:
      ""from .NET with ü -- ö""

      Jboss is receiving this string and post back an array with following to values
      "from .NET with ü -- ö" the String .net sended just post it back
      "Greetings from J with ü -- ö"

      .net output is:
      Sending: from .NET with ü -- ö
      Recived from Jboss Value 1: Greetings from J with ü -- ö
      Recived from Jboss Value 2: from .NET with ü -- ö

      the jboss output is:

      2008-01-05 21:54:36,921 DEBUG [de.Company.test.WebSevices.ServerAgentEndpointBean] from .Net recived: from .NET with ü -- ö

      The interesting thing is happening when the protocol sniffer is on:
      in the Sniffer: .NET is Sending

      POST /SKMS_Server-SKMS_Server/ServerAgentEndpointBean HTTP/1.1
      User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.1433)
      Content-Type: text/xml; charset=utf-8
      SOAPAction: ""
      Host: 127.0.0.1:8080
      Content-Length: 359
      Expect: 100-continue
      Connection: Keep-Alive
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <test xmlns="http://WebSevices.test.company.de/">
      <TestString xmlns="">from .NET with ü -- ö</TestString>
      </test>
      </soap:Body>
      </soap:Envelope>
      
      


      in the Sniffer: Jboss Server is sending back!
      HTTP/1.1 200 OK
      Server: Apache-Coyote/1.1
      X-Powered-By: Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)/Tomcat-5.5
      Content-Type: text/xml;charset=UTF-8
      Transfer-Encoding: chunked
      Date: Sat, 05 Jan 2008 20:54:36 GMT
      
      <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
      <env:Header></env:Header><env:Body>
      <ns2:testResponse xmlns:ns2="http://WebSevices.test.company.de/">
      <return>Greetings from J with �¼ -- �¶</return><return>from .NET with �¼ --
      �¶
      </return></ns2:testResponse></env:Body></env:Envelope>
      



      The .NET Client Code
      test test_remote = new WebReference.test();
      String tesString = "from .NET with ü -- ö";
      test_remote.TestString = tesString;
      
      string[] result = new WebReference.ServerAgentEndpoint().test(test_remote);
      
      Console.WriteLine("Sending: " + tesString);
      Console.WriteLine("Recived from Jboss Value 1: " + result[0]);
      Console.WriteLine("Recived from Jboss Value 2: " + result[1]);
      



      The Java Code is:

      @WebMethod
       public String[] test (@WebParam(name="TestString") String str){
       String[] result = new String[]{"Greetings from J with ü -- ö",str};
       log.debug("from .Net recived: " + str);
       log.debug("This will be the result by Jboss to .Net" + result.toString());
       return result;
       }
      
      
      


      As I see it from the sniffer the .Net client is sendig the data right to jboss encoding the content with utf-8 and jboss is decoding it right.

      When jboss is sending data to .net the data are encoded twice with utf-8
      you can see it in the sniffer.
      .net is sending: from .NET with ü -- ö" <<-- sniffer: encoded once with utf-8
      The line "from J with �¼ -- �¶" <<-- sniffer: utf-8 over utf-8
      .net did it right and encoded it to "from J with ü -- ö" <<-- decoded the string but still one utf-8 encoding is left.

      so i guess something is wrong with the utf-8 encoding in jboss or jbossws?

      can anybody verify my problem?

      greetings

      V.




        • 1. Re: charset problem with jbossws 2.0.2 and .net clients
          Ever Last Newbie

          This is the debug message of the response of the Test(String ping) function from the jboss logs.
          The interesting thing about it is that at the point were the logs were created the values are encoded already in utf-8.
          So the second encoding step is happening somewhere further beyond this point.


          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.EndpointInvocation] setReturnValue: [Ljava.lang.String;
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.MessageContextJAXWS] Begin response processing
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.soap.MessageContextAssociation] popMessageContext: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS@eb91ec (Thread http-127.0.0.1-8080-13)
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.soap.MessageContextAssociation] pushMessageContext: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS@159318b (Thread http-127.0.0.1-8080-13)
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS] bindResponseMessage: {http://WebSevices.test.Company.de/}test
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.EndpointInvocation] getReturnValue
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.EndpointInvocation] transformPayloadValue: [Ljava.lang.String; -> [Ljava.lang.String;
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxrpc.ParameterWrapping] wrapResponseParameter: de.Company.test.WebSevices.jaxws.TestResponse
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.EndpointInvocation] setReturnValue: org.jboss.ws.core.soap.SOAPBodyElementDoc
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS] callResponseHandlerChain: PRE
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS] callResponseHandlerChain: ENDPOINT
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS] callResponseHandlerChain: POST
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS] closeHandlerChain
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] close
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS] closeHandlerChain
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] close
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS] closeHandlerChain
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] close
          2008-01-05 21:54:36,921 DEBUG [org.jboss.wsf.stack.jbws.RequestHandlerImpl] END handleRequest: jboss.ws:context=SKMS_Server-SKMS_Server,endpoint=ServerAgentEndpointBean
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.soap.SOAPContentElement] -----------------------------------
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.soap.SOAPContentElement] Transitioning from OBJECT_VALID to XML_VALID
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.soap.ObjectContent] getXMLFragment from Object [xmlType={http://WebSevices.test.Company.de/}testResponse,javaType=class de.Company.test.WebSevices.jaxws.TestResponse]
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.JAXBSerializer] serialize: [xmlName={http://WebSevices.test.Company.de/}testResponse,xmlType={http://WebSevices.test.Company.de/}testResponse]
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.jaxws.JAXBSerializer] serialized: <ns2:testResponse xmlns:ns2="http://WebSevices.test.Company.de/"><return>Greetings from J with ü -- ö</return><return>from .NET with ü -- ö</return></ns2:testResponse>
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.soap.ObjectContent] xmlFragment: [source=<ns2:testResponse xmlns:ns2="http://WebSevices.test.Company.de/"><return>Greetings from J with ü -- ö</return><return>from .NET with ü -- ö</return></ns2:testResponse>]
          2008-01-05 21:54:36,921 DEBUG [org.jboss.ws.core.soap.SOAPContentElement] -----------------------------------
          


          • 2. Re: charset problem with jbossws 2.0.2 and .net clients
            Frank Heldt Newbie

            Start JBoss with JAVA_OPTS=-Dfile.encoding=UTF-8, that should fix it.

            • 3. Re: charset problem with jbossws 2.0.2 and .net clients
              Ever Last Newbie

              I think I can't use the -Dfile.encoding=UTF-8 option because the 3rd party modules I am using don't work anymore if this option is on.


              Am I right if I say that normally the conversation should be done automatically upon receive of the elements?

              it is working in the forward direction
              .NET (latin1) (auto convert to utf-8) |--->transport channel ( in utf-8)--->| (auto convert to latin1) jboss (Latin1)

              but not in the backward direction (how I expected it would be)
              .NET (latin1) (auto convert to latin1) |<---transport channel (in utf-8)<---| (auto convert to utf-8) jboss (Latin1)

              what really happens is this: (you can see it from my first ans second post)
              .NET (latin1) (auto convert to latin1) |<---transport channel (in utf-8)<---| (second time convert to utf-8)(auto convert to utf-8) jboss (Latin1)

              result is = one utf-8 conversation needed on the .net Side



              Is there any other way to solve this problem then this option with -D-Dfile.encoding=UTF-8 ?

              thank you for help

              Best Regard

              Vadim



              • 4. Re: charset problem with jbossws 2.0.2 and .net clients
                Ever Last Newbie

                What is in general the best solution, best practice to overcome such issues?

                Always enable -Dfile.encoding=UTF-8 option if possible? then why is it not the enabled by standard?

                • 5. Re: charset problem with jbossws 2.0.2 and .net clients
                  Frank Heldt Newbie

                  Well that's a good question and i have no answer...

                  See also: http://jira.jboss.org/jira/browse/JBWS-1716