FileDocCategorySizeDatePackage
SOAPEnvelope.javaAPI DocApache Axis 1.419776Sat Apr 22 18:57:28 BST 2006org.apache.axis.message

SOAPEnvelope

public class SOAPEnvelope extends MessageElement implements SOAPEnvelope
Implementation of a SOAP Envelope

Fields Summary
protected static Log
log
private SOAPHeader
header
private SOAPBody
body
public Vector
trailers
private org.apache.axis.soap.SOAPConstants
soapConstants
private org.apache.axis.schema.SchemaVersion
schemaVersion
public String
messageType
private boolean
recorded
Constructors Summary
public SOAPEnvelope()


     
    
        this(true, SOAPConstants.SOAP11_CONSTANTS);
    
public SOAPEnvelope(org.apache.axis.soap.SOAPConstants soapConstants)

        this(true, soapConstants);
    
public SOAPEnvelope(org.apache.axis.soap.SOAPConstants soapConstants, org.apache.axis.schema.SchemaVersion schemaVersion)

        this(true, soapConstants, schemaVersion);
    
public SOAPEnvelope(boolean registerPrefixes, org.apache.axis.soap.SOAPConstants soapConstants)

        this (registerPrefixes, soapConstants, SchemaVersion.SCHEMA_2001);
    
public SOAPEnvelope(boolean registerPrefixes, org.apache.axis.soap.SOAPConstants soapConstants, org.apache.axis.schema.SchemaVersion schemaVersion)

    
        // FIX BUG http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18108
        super(Constants.ELEM_ENVELOPE,
               Constants.NS_PREFIX_SOAP_ENV,
               (soapConstants != null) ? soapConstants.getEnvelopeURI() : Constants.DEFAULT_SOAP_VERSION.getEnvelopeURI());

        if (soapConstants == null)
          soapConstants = Constants.DEFAULT_SOAP_VERSION;
        // FIX BUG http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18108        
        
        this.soapConstants = soapConstants;
        this.schemaVersion = schemaVersion;
        header = new SOAPHeader(this, soapConstants);
        body = new SOAPBody(this, soapConstants);

        if (registerPrefixes) {
            if (namespaces == null)
                namespaces = new ArrayList();

            namespaces.add(new Mapping(soapConstants.getEnvelopeURI(),
                                       Constants.NS_PREFIX_SOAP_ENV));
            namespaces.add(new Mapping(schemaVersion.getXsdURI(),
                                       Constants.NS_PREFIX_SCHEMA_XSD));
            namespaces.add(new Mapping(schemaVersion.getXsiURI(),
                                       Constants.NS_PREFIX_SCHEMA_XSI));
        }

        setDirty();
    
public SOAPEnvelope(InputStream input)

        InputSource is = new InputSource(input);
        // FIX BUG http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18108
        //header = new SOAPHeader(this, soapConstants); // soapConstants = null!
        header = new SOAPHeader(this, Constants.DEFAULT_SOAP_VERSION); // soapConstants = null!
        // FIX BUG http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18108
        DeserializationContext dser = null ;
        AxisClient     tmpEngine = new AxisClient(new NullProvider());
        MessageContext msgContext = new MessageContext(tmpEngine);
        dser = new DeserializationContext(is, msgContext,
                                          Message.REQUEST, this );
        dser.parse();
    
Methods Summary
public javax.xml.soap.SOAPBodyaddBody()
Add a soap body if one does not exist

return
throws
SOAPException

        if (body == null) {
            body = new SOAPBody(this, soapConstants);
            _isDirty = true;
            body.setOwnerDocument(getOwnerDocument());
            return body;
        } else {
            throw new SOAPException(Messages.getMessage("bodyPresent"));
        }
    
public voidaddBodyElement(SOAPBodyElement element)
Add a SOAP Body Element

param
element

        if (body == null) {
            body = new SOAPBody(this, soapConstants);
        }
        element.setEnvelope(this);
        body.addBodyElement(element);

        _isDirty = true;
    
public voidaddHeader(SOAPHeaderElement hdr)
Add a HeaderElement

param
hdr

        if (header == null) {
            header = new SOAPHeader(this, soapConstants);
        }
        hdr.setEnvelope(this);
        header.addHeader(hdr);
        _isDirty = true;
    
public javax.xml.soap.SOAPHeaderaddHeader()
Add a soap header if one does not exist

return
throws
SOAPException

        if (header == null) {
            header = new SOAPHeader(this, soapConstants);
            header.setOwnerDocument(getOwnerDocument());
            return header;
        } else {
            throw new SOAPException(Messages.getMessage("headerPresent"));
        }
    
public voidaddTrailer(MessageElement element)
Add an element to the trailer

param
element

        if (log.isDebugEnabled())
            log.debug(Messages.getMessage("removeTrailer00"));
        element.setEnvelope(this);
        trailers.addElement(element);
        _isDirty = true;
    
protected voidchildDeepCloned(NodeImpl oldNode, NodeImpl newNode)

        if( oldNode == body )
        {
            body = (SOAPBody)newNode;

            try {
                body.setParentElement(this);
            } catch (SOAPException ex) {
                // class cast should never fail when parent is a SOAPEnvelope
                log.fatal(Messages.getMessage("exception00"), ex);
            }
        }
        else
        if( oldNode == header )
        {
            header = (SOAPHeader)newNode;
        }
    
public voidclearBody()
clear the elements in the soap body

        if (body != null) {
            body.clearBody();
            _isDirty = true;
        }
    
public org.w3c.dom.NodecloneNode(boolean deep)

        SOAPEnvelope envelope = (SOAPEnvelope)super.cloneNode( deep );

        if( !deep )
        {
            envelope.body = null;
            envelope.header = null;
        }

        return envelope;
    
public javax.xml.soap.NamecreateName(java.lang.String localName)
create a Name given the local part

param
localName
return
throws
SOAPException

        return new PrefixedQName(null, localName,  null);
    
public javax.xml.soap.NamecreateName(java.lang.String localName, java.lang.String prefix, java.lang.String uri)
Create a name given local part, prefix and uri

param
localName
param
prefix
param
uri
return
throws
SOAPException

        return new PrefixedQName(uri, localName, prefix);
    
public javax.xml.soap.SOAPBodygetBody()
Get the soap body

return
throws
SOAPException

        return body;
    
public SOAPBodyElementgetBodyByName(java.lang.String namespace, java.lang.String localPart)
Get a body element given its name

param
namespace
param
localPart
return
throws
AxisFault

        if (body == null) {
            return null;
        } else {
            return body.getBodyByName(namespace, localPart);
        }
    
public java.util.VectorgetBodyElements()
Get all the BodyElement's in the soap body

return
vector with body elements
throws
AxisFault

        if (body != null) {
            return body.getBodyElements();
        } else {
            return new Vector();
        }
    
public SOAPBodyElementgetFirstBody()
Get the first BodyElement in the SOAP Body

return
first Body Element
throws
AxisFault

        if (body == null) {
            return null;
        } else {
            return body.getFirstBody();
        }
    
public javax.xml.soap.SOAPHeadergetHeader()
Get the soap header

return
throws
SOAPException

        return header;
    
public SOAPHeaderElementgetHeaderByName(java.lang.String namespace, java.lang.String localPart)
Get a header by name (always respecting the currently in-scope actors list)

        return getHeaderByName(namespace, localPart, false);
    
public SOAPHeaderElementgetHeaderByName(java.lang.String namespace, java.lang.String localPart, boolean accessAllHeaders)
Get a header by name, filtering for headers targeted at this engine depending on the accessAllHeaders parameter.

        if (header != null) {
            return header.getHeaderByName(namespace,
                                          localPart,
                                          accessAllHeaders);
        } else {
            return null;
        }
    
public java.util.VectorgetHeaders()
Get Headers

return
Vector containing Header's
throws
AxisFault

        if (header != null) {
            return header.getHeaders();
        } else {
            return new Vector();
        }
    
public java.util.VectorgetHeadersByActor(java.util.ArrayList actors)
Get all the headers targeted at a list of actors.

        if (header != null) {
            return header.getHeadersByActor(actors);
        } else {
            return new Vector();
        }
    
public java.util.EnumerationgetHeadersByName(java.lang.String namespace, java.lang.String localPart)
Get an enumeration of header elements given the namespace and localpart

param
namespace
param
localPart
return
throws
AxisFault

        return getHeadersByName(namespace, localPart, false);
    
public java.util.EnumerationgetHeadersByName(java.lang.String namespace, java.lang.String localPart, boolean accessAllHeaders)
Return an Enumeration of headers which match the given namespace and localPart. Depending on the value of the accessAllHeaders parameter, we will attempt to filter on the current engine's list of actors. !!! NOTE THAT RIGHT NOW WE ALWAYS ASSUME WE'RE THE "ULTIMATE DESTINATION" (i.e. we match on null actor). IF WE WANT TO FULLY SUPPORT INTERMEDIARIES WE'LL NEED TO FIX THIS.

        if (header != null) {
            return header.getHeadersByName(namespace,
                                           localPart,
                                           accessAllHeaders);
        } else {
            return new Vector().elements();
        }
    
public java.lang.StringgetMessageType()
Get the Message Type (REQUEST/RESPONSE)

return
message type

        return messageType;
    
public org.apache.axis.soap.SOAPConstantsgetSOAPConstants()
Get the soap constants for this envelope

return

        return soapConstants;
    
public org.apache.axis.schema.SchemaVersiongetSchemaVersion()
Get the schema version for this envelope

return

        return schemaVersion;
    
public java.util.VectorgetTrailers()
Return trailers

return
vector of some type

        return trailers;
    
public booleanisRecorded()

        return recorded;
    
public voidoutputImpl(org.apache.axis.encoding.SerializationContext context)
Should make SOAPSerializationException?

        boolean oldPretty = context.getPretty();
        context.setPretty(true);

        // Register namespace prefixes.
        if (namespaces != null) {
            for (Iterator i = namespaces.iterator(); i.hasNext(); ) {
                Mapping mapping = (Mapping)i.next();
                context.registerPrefixForURI(mapping.getPrefix(),
                                             mapping.getNamespaceURI());
            }
        }

        Enumeration enumeration;

        // Output <SOAP-ENV:Envelope>
        context.startElement(new QName(soapConstants.getEnvelopeURI(),
                                       Constants.ELEM_ENVELOPE), attributes);

        
        // Output <SOAP-ENV:Envelope>'s each child as it appears.
        Iterator i = getChildElements();
        while (i.hasNext()) {            
            NodeImpl node = (NodeImpl)i.next();
            
            if (node instanceof SOAPHeader) {
                header.outputImpl(context);
            } else if (node instanceof SOAPBody) {
                body.outputImpl(context);                
            } else if (node instanceof MessageElement) {
                ((MessageElement)node).output(context);
            } else {
                node.output(context);
            }    
        }
        
        // Output trailers
        enumeration = trailers.elements();
        while (enumeration.hasMoreElements()) {
            MessageElement element = (MessageElement)enumeration.nextElement();
            element.output(context);
            // Output this independent element
        }

        // Output </SOAP-ENV:Envelope>
        context.endElement();

        context.setPretty(oldPretty);
    
public voidremoveBody()
Remove the SOAP Body

        if (body != null) {
            removeChild(body);
        }
        body = null;
    
public voidremoveBodyElement(SOAPBodyElement element)
Remove a Body Element from the soap body

param
element

        if (body != null) {
            body.removeBodyElement(element);
            _isDirty = true;
        }
    
public org.w3c.dom.NoderemoveChild(org.w3c.dom.Node oldChild)

        if(oldChild == header) {
            header = null;
        } else if(oldChild == body) {
            body = null;
        }
        return super.removeChild(oldChild);
    
public voidremoveHeader(SOAPHeaderElement hdr)
Remove a Header Element from SOAP Header

param
hdr

        if (header != null) {
            header.removeHeader(hdr);
            _isDirty = true;
        }
    
public voidremoveHeaders()
Remove all headers

        if (header != null) {
            removeChild(header);
        }
        header = null;
    
public voidremoveTrailer(MessageElement element)
Remove an element from the trailer

param
element

        if (log.isDebugEnabled())
            log.debug(Messages.getMessage("removeTrailer00"));
        trailers.removeElement(element);
        _isDirty = true;
    
public voidsetBody(SOAPBody body)
Set the soap body

param
body

        if(this.body != null) {
            removeChild(this.body);
        }
        this.body = body;
        try {
            body.setParentElement(this);
        } catch (SOAPException ex) {
            // class cast should never fail when parent is a SOAPEnvelope
            log.fatal(Messages.getMessage("exception00"), ex);
        }
    
public voidsetDirty(boolean dirty)

        if (recorder != null && !_isDirty && dirty && isRecorded()){
            recorder.clear();
            recorder = null;
        }
        setDirty();
    
public voidsetHeader(SOAPHeader hdr)
Set the SOAP Header

param
hdr

        if(this.header != null) {
            removeChild(this.header);
        }
        header = hdr;
        try {
            header.setParentElement(this);
        } catch (SOAPException ex) {
            // class cast should never fail when parent is a SOAPEnvelope
            log.fatal(Messages.getMessage("exception00"), ex);
        }
    
public voidsetMessageType(java.lang.String messageType)
Set the Message Type (REQUEST/RESPONSE)

param
messageType

        this.messageType = messageType;
    
public voidsetOwnerDocument(org.apache.axis.SOAPPart sp)

        super.setOwnerDocument(sp);
        if(body != null) {
            body.setOwnerDocument(sp);
            setOwnerDocumentForChildren(((NodeImpl)body).children, sp);
        }
        if(header != null){
            header.setOwnerDocument(sp);
            setOwnerDocumentForChildren(((NodeImpl)body).children, sp);
        }
    
private voidsetOwnerDocumentForChildren(java.util.List children, org.apache.axis.SOAPPart sp)

    	if (children == null) {
            return;
        }
        int size = children.size();
        for (int i = 0; i < size; i++) {
            NodeImpl node = (NodeImpl) children.get(i);
            node.setOwnerDocument(sp);
            setOwnerDocumentForChildren(node.children, sp);  // recursively
    	}
    
public voidsetRecorded(boolean recorded)

        this.recorded = recorded;
    
public voidsetSAAJEncodingCompliance(boolean comply)

        this.body.setSAAJEncodingCompliance(comply);
    
public voidsetSchemaVersion(org.apache.axis.schema.SchemaVersion schemaVersion)
Set the schema version for this envelope

param
schemaVersion

        this.schemaVersion = schemaVersion;
    
public voidsetSoapConstants(org.apache.axis.soap.SOAPConstants soapConstants)
Set the soap constants for this envelope

param
soapConstants

        this.soapConstants = soapConstants;