2 Replies Latest reply on Feb 3, 2006 1:48 PM by msell

    Error: Invalid byte 1 of 1-byte UTF-8 sequence

    msell

      Using JBoss-Head, have a simple JSR-181 webservice exposed using Document/Literal - this service accepts a string and returns the string. I'm using it to test various client SOAP libraries.

      Some characters are producing the error listed in the subject. For example, the following SOAP envelope generates the error:

      (Unicode character #160 for example:)

      Content-Type: text/xml; charset=utf-8
      Accept: application/soap+xml, application/dime, multipart/related, text/*
      User-Agent: Axis/1.2.1
      Host: 129.196.137.104:8080
      Cache-Control: no-cache
      Pragma: no-cache
      SOAPAction: ""
      Content-Length: 399

      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <soapenv:Body>

      <String_1>746A7570-A9D2-393A-0A3A-B92EE2F5A823</String_1>
      <String_2>¢</String_2>

      </soapenv:Body>

      </soapenv:Envelope>


      The error:

      16:55:53,223 ERROR [STDERR] [Fatal Error] :1:275: Invalid byte 1 of 1-byte UTF-8 sequence.
      16:55:53,223 ERROR [DOMUtils] Cannot parse: <wrapper xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><String_1>746A7570-A9D2-393A-0A3A-B92EE2F5A823</String_1><String_2>¢</String_2>
      16:55:53,223 ERROR [ServiceEndpoint] SOAP request exception
      javax.xml.rpc.JAXRPCException: java.io.IOException: org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
      at org.jboss.ws.soap.SOAPContentElement.expandToDOM(SOAPContentElement.java:887)
      at org.jboss.ws.soap.SOAPContentElement.getChildNodes(SOAPContentElement.java:755)
      at org.jboss.util.xml.DOMWriter.printInternal(DOMWriter.java:166)
      at org.jboss.util.xml.DOMWriter.printInternal(DOMWriter.java:225)
      at org.jboss.util.xml.DOMWriter.printInternal(DOMWriter.java:225)
      at org.jboss.util.xml.DOMWriter.print(DOMWriter.java:144)
      at org.jboss.util.xml.DOMWriter.printNode(DOMWriter.java:93)
      at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:216)
      at org.jboss.ws.server.ServiceEndpointServlet.doPost(ServiceEndpointServlet.java:110)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:173)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.io.IOException: org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
      at org.jboss.util.xml.DOMUtils.parse(DOMUtils.java:117)
      at org.jboss.util.xml.DOMUtils.parse(DOMUtils.java:96)
      at org.jboss.ws.soap.SOAPContentElement.expandToDOM(SOAPContentElement.java:843)
      ... 29 more


      Am I missing something really simple here? I have a test case that can generate a list of the individual characters that produce this error, but should be acceptable normally.

      Thanks for any insight!


        • 1. Re: Error: Invalid byte 1 of 1-byte UTF-8 sequence
          anders.hedstrom

          The character needs to be UTF-8 encoded:

          Content-Type: text/xml; charset=utf-8
          
          Accept: application/soap+xml, application/dime, multipart/related, text/*
          
          User-Agent: Axis/1.2alpha
          
          Host: 127.0.0.1
          
          Cache-Control: no-cache
          
          Pragma: no-cache
          
          SOAPAction: "doProcess"
          
          Content-Length: 353
          
          
          
          <?xml version="1.0" encoding="UTF-8"?>
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           <soapenv:Body>
           <String_1>746A7570-A9D2-393A-0A3A-B92EE2F5A823</String_1>
           <String_2>¢</String_2>
           </soapenv:Body>
          </soapenv:Envelope>


          • 2. Re: Error: Invalid byte 1 of 1-byte UTF-8 sequence
            msell

            Hmmm.... okay...

            The actual character sequence that I see on the wire (using Ethereal) is the following:

            <String_2>#xA0;</String_2>

            (There is an ampersand (&) before the pound sign)

            The character I sent is visible on the console in the error.