Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-3411

WSDL generation for javax.jws SOAP services uses system-default character set.

    XMLWordPrintable

Details

    • Hide

      1. Start a JBoss in a JVM with start parameter -Dfile.encoding=ISO-8859-1
      2. Deploy this webservice:

      @javax.ejb.Stateless
      @javax.jws.WebService
      @javax.jws.soap.SOAPBinding
      public class Utf8WebServiceTest {
      public void get\u00e0() {}
      }

      3. Observe Exception being thrown:
      2012-01-11 11:08:51,560 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/D:/servers/JBoss/server/all/deploy/test.jar state=PreReal mode=Manual requiredState=Real
      org.jboss.deployers.spi.DeploymentException: Error during deploy: vfsfile:/D:/servers/JBoss/server/all/deploy/test.jar
      at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
      (...)
      Caused by: org.apache.xerces.xni.XNIException: Parser should stop: JBossWS__3368880279557821828.xsd[domain:http://www.w3.org/TR/1998/REC-xml-19980210]::[key=InvalidByte]::Message=Invalid byte 2 of 3-byte UTF-8 sequence.
      at org.jboss.ws.metadata.wsdl.xmlschema.JBossXSErrorHandler.fatalError(JBossXSErrorHandler.java:78)
      (...)
      at org.jboss.ws.tools.JavaToXSD.parseSchema(JavaToXSD.java:183)
      (...)

      Show
      1. Start a JBoss in a JVM with start parameter -Dfile.encoding=ISO-8859-1 2. Deploy this webservice: @javax.ejb.Stateless @javax.jws.WebService @javax.jws.soap.SOAPBinding public class Utf8WebServiceTest { public void get\u00e0() {} } 3. Observe Exception being thrown: 2012-01-11 11:08:51,560 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/D:/servers/JBoss/server/all/deploy/test.jar state=PreReal mode=Manual requiredState=Real org.jboss.deployers.spi.DeploymentException: Error during deploy: vfsfile:/D:/servers/JBoss/server/all/deploy/test.jar at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) (...) Caused by: org.apache.xerces.xni.XNIException: Parser should stop: JBossWS__3368880279557821828.xsd [domain:http://www.w3.org/TR/1998/REC-xml-19980210] ::[key=InvalidByte]::Message=Invalid byte 2 of 3-byte UTF-8 sequence. at org.jboss.ws.metadata.wsdl.xmlschema.JBossXSErrorHandler.fatalError(JBossXSErrorHandler.java:78) (...) at org.jboss.ws.tools.JavaToXSD.parseSchema(JavaToXSD.java:183) (...)

    Description

      When deploying a webservice implemented using javax.jws and JAXB annotations, a WSDL is generated. In this process, a temporary XML schema file is generated and written to the tmp directory by the WSDL11Reader.processSchemaInclude method. It uses a DOMWriter in lines 640-646 to actually write the file via a FileWriter. This leads to the schema being written with the system-default character set, without an XML declaration. For non-ASCII characters, this might in turn lead to org.apache.xerces.xni.XNIException being thrown by the xerces parser when the file is read again by the JavaToXSD.parseSchema (line 181) method.

      For example, part of my I have an @XmlEnum with a value "località", specified by @XmlEnumValue("localit\u00e0"), which causes this problem. The exception message in this case is
      "Parser should stop: JBossWS_(...)18444939893360070.xsd[domain:http://www.w3.org/TR/1998/REC-xml-19980210]::[key=InvalidByte]::Message=Invalid byte 2 of 3-byte UTF-8 sequence."

      Java char supports UTF-16 characters with the "\u" escape sequences. The DOMWriter has another constructor DOMWriter(OutputStream stream, String charsetName) which also causes an XML declaration to be written. Its usage in WSDL11Reader with "UTF-16" as second parameter would thus avoid the described problem.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ivu-bab Bastian Blankenburg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: