JDK-8159058 : SAXParseException when sending soap message
  • Type: Bug
  • Component: xml
  • Sub-Component: jax-ws
  • Affected Version: 8u91,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-06-08
  • Updated: 2018-02-08
  • Resolved: 2017-01-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u121Fixed 9 b153Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
The SOAP message with empty default namespace (xmlns="") sent to WS can result in incorrect message received on WS handler side.

SOAP message sent to WS:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
    <SampleServiceRequest xmlns="http://test.example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <RequestParams xmlns="">
            <Param1>Param1_Value</Param1>
            <Param2>Param2_Value</Param2>
        </RequestParams>
    </SampleServiceRequest>
</s:Body>
</s:Envelope>

Message received on WS handler side:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<s:Body>
    <SampleServiceRequest xmlns="http://test.example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <RequestParams xmlns="http://test.example.com">
            <Param1 xmlns="">Param1_Value</Param1>
            <Param2 xmlns="">Param2_Value</Param2>
        </RequestParams>
    </SampleServiceRequest>
</s:Body>
</s:Envelope>

The <RequestParams> has incorrect default namespace set:  xmlns="http://test.example.com">, it should be xmlns="" instead.

The incorrect message can cause SAXParseException during the validation of the received message:
org.xml.sax.SAXParseException; cvc-complex-type.2.4.a: Invalid content was found starting with element 'RequestParams'. One of '{RequestParams}' is expected.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1790)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
	at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:277)
	at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:244)
	at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:190)
	at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:109)
	at javax.xml.validation.Validator.validate(Validator.java:124)
	at sample.server.ws.handler.SampleHandler.handleMessage(SampleHandler.java:45)

Comments
OpenJDK review thread: http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-January/045785.html
09-01-2017

Counterpart bug created in JAXWS tracker: https://java.net/jira/browse/JAX_WS-1188
05-01-2017