src/share/jaxws_classes/com/sun/xml/internal/ws/message/stream/StreamMessage.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 48,68 ****
import com.sun.xml.internal.ws.spi.db.XMLBridge;
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
import com.sun.xml.internal.ws.util.xml.DummyLocation;
import com.sun.xml.internal.ws.util.xml.StAXSource;
import com.sun.xml.internal.ws.util.xml.XMLReaderComposite;
! import com.sun.xml.internal.ws.util.xml.XMLStreamReaderToXMLStreamWriter;
import com.sun.xml.internal.ws.util.xml.XMLReaderComposite.ElemInfo;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.NamespaceSupport;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.stream.*;
import static javax.xml.stream.XMLStreamConstants.START_DOCUMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
--- 48,69 ----
import com.sun.xml.internal.ws.spi.db.XMLBridge;
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
import com.sun.xml.internal.ws.util.xml.DummyLocation;
import com.sun.xml.internal.ws.util.xml.StAXSource;
import com.sun.xml.internal.ws.util.xml.XMLReaderComposite;
! import com.sun.xml.internal.org.jvnet.staxex.util.XMLStreamReaderToXMLStreamWriter;
import com.sun.xml.internal.ws.util.xml.XMLReaderComposite.ElemInfo;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.NamespaceSupport;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
+ import javax.xml.namespace.QName;
import javax.xml.stream.*;
import static javax.xml.stream.XMLStreamConstants.START_DOCUMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
*** 413,427 ****
public void writeTo(XMLStreamWriter sw) throws XMLStreamException{
if ( envelopeReader != null ) readEnvelope(this);
writeEnvelope(sw);
}
! /**
! * This method should be called when the StreamMessage is created with a payload
! * @param writer
! */
! private void writeEnvelope(XMLStreamWriter writer) throws XMLStreamException {
if ( envelopeReader != null ) readEnvelope(this);
writer.writeStartDocument();
envelopeTag.writeStart(writer);
//write headers
--- 414,424 ----
public void writeTo(XMLStreamWriter sw) throws XMLStreamException{
if ( envelopeReader != null ) readEnvelope(this);
writeEnvelope(sw);
}
! public void writeToBodyStart(XMLStreamWriter writer) throws XMLStreamException {
if ( envelopeReader != null ) readEnvelope(this);
writer.writeStartDocument();
envelopeTag.writeStart(writer);
//write headers
*** 435,444 ****
--- 432,450 ----
}
}
writer.writeEndElement();
}
bodyTag.writeStart(writer);
+
+ }
+
+ /**
+ * This method should be called when the StreamMessage is created with a payload
+ * @param writer
+ */
+ private void writeEnvelope(XMLStreamWriter writer) throws XMLStreamException {
+ writeToBodyStart(writer);
if(hasPayload())
writePayloadTo(writer);
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndDocument();
*** 548,558 ****
// advance to the start tag of the <Body> first child element
proceedToRootElement(reader);
proceedToRootElement(clone);
! return new StreamMessage(envelopeTag, headerTag, attachmentSet, HeaderList.copy(headers), bodyPrologue, bodyTag, bodyEpilogue, clone, soapVersion);
} catch (XMLStreamException e) {
throw new WebServiceException("Failed to copy a message",e);
}
}
--- 554,564 ----
// advance to the start tag of the <Body> first child element
proceedToRootElement(reader);
proceedToRootElement(clone);
! return new StreamMessage(envelopeTag, headerTag, attachmentSet, HeaderList.copy(headers), bodyPrologue, bodyTag, bodyEpilogue, clone, soapVersion).copyFrom(this);
} catch (XMLStreamException e) {
throw new WebServiceException("Failed to copy a message",e);
}
}
*** 761,766 ****
--- 767,798 ----
// since it is more efficient. ISSUE: possible issue with
// lifetime of information in the buffer if accessed beyond
// the pipe line.
return new MutableXMLStreamBuffer();
}
+
+ public boolean isPayloadStreamReader() { return true; }
+
+ public QName getPayloadQName() {
+ return this.hasPayload() ? new QName(payloadNamespaceURI, payloadLocalName) : null;
+ }
+
+ public XMLStreamReader readToBodyStarTag() {
+ if ( envelopeReader != null ) readEnvelope(this);
+ List<XMLStreamReader> hReaders = new java.util.ArrayList<XMLStreamReader>();
+ ElemInfo envElem = new ElemInfo(envelopeTag, null);
+ ElemInfo hdrElem = (headerTag != null) ? new ElemInfo(headerTag, envElem) : null;
+ ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
+ for (Header h : getHeaders().asList()) {
+ try {
+ hReaders.add(h.readHeader());
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ XMLStreamReader soapHeader = (hdrElem != null) ? new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[hReaders.size()])) : null;
+ XMLStreamReader[] payload = {};
+ XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, payload);
+ XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[]{soapHeader, soapBody} : new XMLStreamReader[]{soapBody};
+ return new XMLReaderComposite(envElem, soapContent);
+ }
}