CLONE - Streambuffer cannot parse namespaces presented in the SOAP envelope level
@glassfishrobot is already working on this.
Since Sep 21, 2018.
Assessment
This issue has not been assessed yet.
Description
We're using the below code snippet to parse SOAP header:
private ServiceContext getDeltaContext (SOAPMessageContext context)
{ Object[] jaxbServiceContext = context.getHeaders(new QName(DFS_CONTEXT_NAMESPACE, "ServiceContext"), SERVICE_CONTEXT_JAXB_CONTEXT, false); ... }
The above code will finally depend on streambuffer to parse the SOAP message. However, we hit the below exception when parsing the attached SOAP message (note that the namespaces are in the envelope level):
Caused by: javax.xml.bind.JAXBException
- with linked exception:
[java.lang.IllegalArgumentException: prefix tns is not bound to a namespace]
at com.sun.xml.ws.message.AbstractHeaderImpl.readAsJAXB(AbstractHeaderImpl.java:81)
at com.sun.xml.ws.handler.SOAPMessageContextImpl.getHeaders(SOAPMessageContextImpl.java:127)
... 34 more
Caused by: java.lang.IllegalArgumentException: prefix tns is not bound to a namespace
at com.sun.xml.bind.DatatypeConverterImpl._parseQName(DatatypeConverterImpl.java:341)
at com.sun.xml.bind.v2.runtime.unmarshaller.XsiTypeLoader.parseXsiType(XsiTypeLoader.java:89)
at com.sun.xml.bind.v2.runtime.unmarshaller.XsiTypeLoader.startElement(XsiTypeLoader.java:67)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:481)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:71)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:332)
at com.sun.xml.ws.message.AbstractHeaderImpl.readAsJAXB(AbstractHeaderImpl.java:79)
... 35 more
After initial investigation, we found this should be caused by a streambuffer bug. If we update the implementation of com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.setXMLStreamBuffer(XMLStreamBuffer buffer) like below, the issue can be resolved:
public void setXMLStreamBuffer(XMLStreamBuffer buffer) throws XMLStreamException {
setBuffer(buffer,buffer.isFragment());
_completionState = PARSING;
_namespaceAIIsEnd = buffer.getInscopeNamespaces().size();
Set<Entry<String, String>> entries = buffer.getInscopeNamespaces().entrySet();
Iterator<Entry<String, String>> it = entries.iterator();
int i = 0;
while(it.hasNext() && i < _namespaceAIIsEnd)
{ Entry<String, String> entry = it.next(); _namespaceAIIsPrefix[i] = entry.getKey(); _namespaceAIIsNamespaceName[i] = entry.getValue(); i++; }
_characters = null;
_charSequence = null;
_eventType = START_DOCUMENT;
}
Streambuffer 1.1 also has this bug.
Btw, at first we were using SOAPMessageContext.getMessage().getSOAPHeader()to parse the SOAP header but there is OOM issue with large MTOM message.
Environment
NA
Affected Versions
[1.5.2]
- Dominant language
- Java
- Stars
- 1
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from eclipse-ee4j/metro-xmlstreambuffer
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
eclipse-ee4j/metro-xmlstreambuffer#71 · 1 reaction ·
All issues in eclipse-ee4j/metro-xmlstreambuffer
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
inu-appcenter/memorIN-backend#288 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
frontend maui-pilot pilot-ask question
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
area/plugin
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
kestra-io/plugin-kestra#190 ·