1 16 package org.apache.axis2.soap.impl.llom; 17 18 import org.apache.axis2.om.*; 19 import org.apache.axis2.soap.SOAPBody; 20 import org.apache.axis2.soap.SOAPEnvelope; 21 import org.apache.axis2.soap.SOAPHeader; 22 23 import javax.xml.namespace.QName ; 24 25 28 public class SOAPEnvelopeImpl extends SOAPElement 29 implements SOAPEnvelope, OMConstants { 30 31 34 public SOAPEnvelopeImpl(OMXMLParserWrapper builder) { 35 super(null, SOAPConstants.SOAPENVELOPE_LOCAL_NAME, builder); 36 } 37 38 41 public SOAPEnvelopeImpl(OMNamespace ns) { 42 super(SOAPConstants.SOAPENVELOPE_LOCAL_NAME, ns); 43 } 44 45 57 public SOAPHeader getHeader() throws OMException { 58 return (SOAPHeader) getFirstChildWithName(new QName (SOAPConstants.HEADER_LOCAL_NAME)); 59 } 60 61 72 public SOAPBody getBody() throws OMException { 73 OMElement element = getFirstElement(); 75 if (element != null) { 76 if (SOAPConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) { 77 return (SOAPBody) element; 78 } else { OMNode node = element.getNextSibling(); 80 while (node != null && node.getType() != OMNode.ELEMENT_NODE) { 81 node = node.getNextSibling(); 82 } 83 element = (OMElement) node; 84 85 if (node != null && SOAPConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) { 86 return (SOAPBody) element; 87 } else { 88 throw new OMException("SOAPEnvelope must contain a body element which is either first or second child element of the SOAPEnvelope."); 89 } 90 } 91 } 92 return null; 93 } 94 95 100 public OMNode detach() throws OMException { 101 throw new OMException("Root Element can not be detached"); 102 } 103 104 protected void checkParent(OMElement parent) throws SOAPProcessingException { 105 } 107 } 108 | Popular Tags |