src/share/jaxws_classes/com/sun/xml/internal/ws/message/AbstractMessageImpl.java
Print this page
*** 23,42 ****
--- 23,46 ----
* questions.
*/
package com.sun.xml.internal.ws.message;
+ import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.bind.api.Bridge;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.api.message.Header;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.MessageHeaders;
import com.sun.xml.internal.ws.api.message.MessageWritable;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.message.saaj.SAAJFactory;
+ import com.sun.xml.internal.ws.encoding.TagInfoset;
import com.sun.xml.internal.ws.message.saaj.SAAJMessage;
import com.sun.xml.internal.ws.spi.db.XMLBridge;
+ import java.util.ArrayList;
+ import java.util.Collections;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.LocatorImpl;
*** 78,128 ****
--- 82,161 ----
* So if you aren't using those methods that use this field,
* this can be null.
*/
protected final SOAPVersion soapVersion;
+ protected @NotNull TagInfoset envelopeTag;
+ protected @NotNull TagInfoset headerTag;
+ protected @NotNull TagInfoset bodyTag;
+
+ protected static final AttributesImpl EMPTY_ATTS;
+ protected static final LocatorImpl NULL_LOCATOR = new LocatorImpl();
+ protected static final List<TagInfoset> DEFAULT_TAGS;
+
+ static void create(SOAPVersion v, List c) {
+ int base = v.ordinal()*3;
+ c.add(base, new TagInfoset(v.nsUri, "Envelope", "S", EMPTY_ATTS,"S", v.nsUri));
+ c.add(base+1, new TagInfoset(v.nsUri, "Header", "S", EMPTY_ATTS));
+ c.add(base+2, new TagInfoset(v.nsUri, "Body", "S", EMPTY_ATTS));
+ }
+
+ static {
+ EMPTY_ATTS = new AttributesImpl();
+ List<TagInfoset> tagList = new ArrayList<TagInfoset>();
+ create(SOAPVersion.SOAP_11, tagList);
+ create(SOAPVersion.SOAP_12, tagList);
+ DEFAULT_TAGS = Collections.unmodifiableList(tagList);
+ }
+
protected AbstractMessageImpl(SOAPVersion soapVersion) {
this.soapVersion = soapVersion;
}
+ @Override
public SOAPVersion getSOAPVersion() {
return soapVersion;
}
/**
* Copy constructor.
*/
protected AbstractMessageImpl(AbstractMessageImpl that) {
this.soapVersion = that.soapVersion;
}
+ @Override
public Source readEnvelopeAsSource() {
return new SAXSource(new XMLReaderImpl(this), XMLReaderImpl.THE_SOURCE);
}
+ @Override
public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
if(hasAttachments())
unmarshaller.setAttachmentUnmarshaller(new AttachmentUnmarshallerImpl(getAttachments()));
try {
return (T) unmarshaller.unmarshal(readPayloadAsSource());
} finally{
unmarshaller.setAttachmentUnmarshaller(null);
}
}
/** @deprecated */
+ @Override
public <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException {
return bridge.unmarshal(readPayloadAsSource(),
hasAttachments()? new AttachmentUnmarshallerImpl(getAttachments()) : null );
}
+ @Override
public <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException {
return bridge.unmarshal(readPayloadAsSource(),
hasAttachments()? new AttachmentUnmarshallerImpl(getAttachments()) : null );
}
/**
* Default implementation that relies on {@link #writePayloadTo(XMLStreamWriter)}
*/
+ @Override
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
String soapNsUri = soapVersion.nsUri;
w.writeStartDocument();
w.writeStartElement("S","Envelope",soapNsUri);
w.writeNamespace("S",soapNsUri);
*** 145,154 ****
--- 178,188 ----
}
/**
* Writes the whole envelope as SAX events.
*/
+ @Override
public void writeTo( ContentHandler contentHandler, ErrorHandler errorHandler ) throws SAXException {
String soapNsUri = soapVersion.nsUri;
contentHandler.setDocumentLocator(NULL_LOCATOR);
contentHandler.startDocument();
*** 189,205 ****
}
/**
* Default implementation that uses {@link #writeTo(ContentHandler, ErrorHandler)}
*/
public SOAPMessage readAsSOAPMessage() throws SOAPException {
return SAAJFactory.read(soapVersion, this);
}
! /**
! *
! */
public SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws SOAPException {
SOAPMessage msg = SAAJFactory.read(soapVersion, this, packet);
transportHeaders(packet, inbound, msg);
return msg;
}
--- 223,238 ----
}
/**
* Default implementation that uses {@link #writeTo(ContentHandler, ErrorHandler)}
*/
+ @Override
public SOAPMessage readAsSOAPMessage() throws SOAPException {
return SAAJFactory.read(soapVersion, this);
}
! @Override
public SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws SOAPException {
SOAPMessage msg = SAAJFactory.read(soapVersion, this, packet);
transportHeaders(packet, inbound, msg);
return msg;
}
*** 209,217 ****
if (headers != null) {
addSOAPMimeHeaders(msg.getMimeHeaders(), headers);
}
if (msg.saveRequired()) msg.saveChanges();
}
-
- protected static final AttributesImpl EMPTY_ATTS = new AttributesImpl();
- protected static final LocatorImpl NULL_LOCATOR = new LocatorImpl();
}
--- 242,247 ----