private void materializePayload() throws SOAPException { if (staxBridge != null) { if (payloadStreamRead) { //the payload has already been read via stream reader and the //stream has been exhausted already. Throw an //exception since we are now trying to materialize as DOM and //there is no stream left to read throw new SOAPException("SOAPBody payload stream has been fully read - cannot materialize as DOM!"); } try { staxBridge.bridgePayload(); staxBridge = null; payloadStreamRead = true; } catch (XMLStreamException e) { throw new SOAPException(e); } } }
XMLStreamReader getPayloadReader() { return staxBridge.getPayloadReader(); }
private static Envelope parseEnvelopeStax(Source src, SOAPPartImpl soapPart) throws SOAPException { XMLStreamReader streamReader = null; if (src instanceof StAXSource) { streamReader = ((StAXSource) src).getXMLStreamReader(); } try { if (streamReader == null) { if (xmlInputFactory == null) xmlInputFactory = XMLInputFactory.newInstance(); streamReader = xmlInputFactory.createXMLStreamReader(src); } // SaajStaxWriter saajWriter = new SaajStaxWriter(soapPart.message, soapPart.document); // XMLStreamReaderToXMLStreamWriter readerWriterBridge = new XMLStreamReaderToXMLStreamWriter( // streamReader, saajWriter, soapPart.getSOAPNamespace()); StaxBridge readerWriterBridge = new StaxReaderBridge(streamReader, soapPart); //bridge will stop reading at body element, and parse upon request, so save it //on the envelope readerWriterBridge.bridgeEnvelopeAndHeaders(); Envelope env = (Envelope) soapPart.getEnvelope(); env.setStaxBridge(readerWriterBridge); return env; } catch (Exception e) { throw new SOAPException(e); } } private static Envelope parseEnvelopeSax(Source src, SOAPPartImpl soapPart)
public LazyEnvelopeStaxReader(EnvelopeImpl env) throws SOAPException, XMLStreamException { super(env); // this.env = env; bodyQName = new QName(env.getNamespaceURI(), "Body"); payloadReader = env.getStaxBridge().getPayloadReader(); int eventType = getEventType(); while (eventType != START_ELEMENT) { eventType = nextTag(); } }