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

SOAPBody

public class SOAPBody extends MessageElement implements SOAPBody
Holder for body elements.
author
Glyn Normington (glyn@apache.org)

Fields Summary
private static Log
log
private org.apache.axis.soap.SOAPConstants
soapConstants
private boolean
disableFormatting
private boolean
doSAAJEncodingCompliance
private static ArrayList
knownEncodingStyles
Constructors Summary
SOAPBody(SOAPEnvelope env, org.apache.axis.soap.SOAPConstants soapConsts)


     
        knownEncodingStyles.add(Constants.URI_SOAP11_ENC);
        knownEncodingStyles.add(Constants.URI_SOAP12_ENC);
        knownEncodingStyles.add("");
        knownEncodingStyles.add(Constants.URI_SOAP12_NOENC);
    
       super(soapConsts.getEnvelopeURI(), Constants.ELEM_BODY);
       soapConstants = soapConsts;
        try {
            setParentElement(env);
        } catch (SOAPException ex) {
            // class cast should never fail when parent is a SOAPEnvelope
            log.fatal(Messages.getMessage("exception00"), ex);
        }
    
public SOAPBody(String namespace, String localPart, String prefix, Attributes attributes, org.apache.axis.encoding.DeserializationContext context, org.apache.axis.soap.SOAPConstants soapConsts)

        super(namespace, localPart, prefix, attributes, context);
        soapConstants = soapConsts;
    
Methods Summary
public javax.xml.soap.SOAPBodyElementaddBodyElement(javax.xml.soap.Name name)

        SOAPBodyElement bodyElement = new SOAPBodyElement(name);
        addChildElement(bodyElement);
        return bodyElement;
    
voidaddBodyElement(SOAPBodyElement element)

        if (log.isDebugEnabled())
            log.debug(Messages.getMessage("addBody00"));
        try {
            addChildElement(element);
        } catch (SOAPException ex) {
            // class cast should never fail when parent is a SOAPBody
            log.fatal(Messages.getMessage("exception00"), ex);
        }
    
public voidaddChild(MessageElement element)

// Commented out for SAAJ compatibility - gdaniels, 05/19/2003
//      if (!(element instanceof javax.xml.soap.SOAPBodyElement)) {
//        throw new SOAPException(Messages.getMessage("badSOAPBodyElement00"));
//      }
        element.setEnvelope(getEnvelope());
        super.addChild(element);
    
public javax.xml.soap.SOAPElementaddChildElement(javax.xml.soap.SOAPElement element)

// Commented out for SAAJ compatibility - gdaniels, 05/19/2003
//      if (!(element instanceof javax.xml.soap.SOAPBodyElement)) {
//        throw new SOAPException(Messages.getMessage("badSOAPBodyElement00"));
//      }
        SOAPElement child = super.addChildElement(element);
        setDirty();
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(javax.xml.soap.Name name)

        SOAPBodyElement child = new SOAPBodyElement(name);
        addChildElement(child);
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(java.lang.String localName)

        // Inherit parent's namespace
        SOAPBodyElement child = new SOAPBodyElement(getNamespaceURI(),
                                                    localName);
        addChildElement(child);
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(java.lang.String localName, java.lang.String prefix)

        SOAPBodyElement child = 
            new SOAPBodyElement(getNamespaceURI(prefix), localName);
        child.setPrefix(prefix);
        addChildElement(child);
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(java.lang.String localName, java.lang.String prefix, java.lang.String uri)

        SOAPBodyElement child = new SOAPBodyElement(uri, localName);
        child.setPrefix(prefix);
        child.addNamespaceDeclaration(prefix, uri);
        addChildElement(child);
        return child;
    
public javax.xml.soap.SOAPBodyElementaddDocument(org.w3c.dom.Document document)

        SOAPBodyElement bodyElement = new SOAPBodyElement(document.getDocumentElement());
        addChildElement(bodyElement);
        return bodyElement;
    
public javax.xml.soap.SOAPFaultaddFault(javax.xml.soap.Name name, java.lang.String s, java.util.Locale locale)

        AxisFault af = new AxisFault(new QName(name.getURI(), name.getLocalName()), s, "", new Element[0]);
        SOAPFault fault = new SOAPFault(af);
        addChildElement(fault);
        return fault;
    
public javax.xml.soap.SOAPFaultaddFault(javax.xml.soap.Name name, java.lang.String s)

        AxisFault af = new AxisFault(new QName(name.getURI(), name.getLocalName()), s, "", new Element[0]);
        SOAPFault fault = new SOAPFault(af);
        addChildElement(fault);
        return fault;
    
public javax.xml.soap.SOAPFaultaddFault()

        
        AxisFault af = new AxisFault(new QName(Constants.NS_URI_AXIS, Constants.FAULT_SERVER_GENERAL), "", "", new Element[0]);
        SOAPFault fault = new SOAPFault(af);
        addChildElement(fault);
        return fault;
    
voidclearBody()

        removeContents();
    
public voiddisableFormatting()

        this.disableFormatting = true;
    
SOAPBodyElementgetBodyByName(java.lang.String namespace, java.lang.String localPart)

        QName name = new QName(namespace, localPart);
        return (SOAPBodyElement)getChildElement(name);
    
java.util.VectorgetBodyElements()

        initializeChildren();
        return new Vector(getChildren());
    
public javax.xml.soap.SOAPFaultgetFault()

        List bodyElements = getChildren();
        if (bodyElements != null) {
            Iterator e = bodyElements.iterator();
            while (e.hasNext()) {
                Object element = e.next();
                if(element instanceof javax.xml.soap.SOAPFault) {
                    return (javax.xml.soap.SOAPFault) element;
                }
            }
        }
        return null;
    
SOAPBodyElementgetFirstBody()

        if (!hasChildNodes())
            return null;
        return (SOAPBodyElement)getChildren().get(0);
    
public booleanhasFault()

        return (getFault() != null);
    
protected voidoutputImpl(org.apache.axis.encoding.SerializationContext context)

        boolean oldPretty = context.getPretty();
        if (!disableFormatting) {
             context.setPretty(true);
        } else {
             context.setPretty(false);
        }

        List bodyElements = getChildren();

        if (bodyElements == null || bodyElements.isEmpty()) {
            // This is a problem.
            // throw new Exception("No body elements!");
            // If there are no body elements just return - it's ok that
            // the body is empty
        }

        // Output <SOAP-ENV:Body>
        context.startElement(new QName(soapConstants.getEnvelopeURI(),
                                       Constants.ELEM_BODY),
                             getAttributesEx());
        
        if (bodyElements != null) {
            Iterator e = bodyElements.iterator();
            while (e.hasNext()) {
                MessageElement body = (MessageElement)e.next();
                body.output(context);
                // Output this body element.
            }
        }
        
        // Output multi-refs if appropriate
        context.outputMultiRefs();
        
        // Output </SOAP-ENV:Body>
        context.endElement();

        context.setPretty(oldPretty);
    
voidremoveBodyElement(SOAPBodyElement element)

        if (log.isDebugEnabled())
            log.debug(Messages.getMessage("removeBody00"));
        removeChild( (MessageElement)element );
    
public voidsetEncodingStyle(java.lang.String encodingStyle)

        if (encodingStyle == null) {
            encodingStyle = "";
        }

        if (doSAAJEncodingCompliance) {
            // Make sure this matches a known encodingStyle.  This is
            if (!knownEncodingStyles.contains(encodingStyle))
                throw new IllegalArgumentException(Messages.getMessage("badEncodingStyle1", encodingStyle));
        }

        super.setEncodingStyle(encodingStyle);
    
public voidsetParentElement(javax.xml.soap.SOAPElement parent)

        if(parent == null) {
            throw new IllegalArgumentException(Messages.getMessage("nullParent00")); 
        }
        try {
            SOAPEnvelope env = (SOAPEnvelope)parent;
            super.setParentElement(env);
            setEnvelope(env);
        } catch (Throwable t) {
            throw new SOAPException(t);
        }
    
public voidsetSAAJEncodingCompliance(boolean comply)

        this.doSAAJEncodingCompliance = true;