|
Duplicate :
|
|
|
Duplicate :
|
|
|
Relates :
|
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)
|