1 package org.apache.axis2.soap.impl.llom.soap11; 2 3 import org.apache.axis2.om.OMElement; 4 import org.apache.axis2.om.OMNamespace; 5 import org.apache.axis2.om.OMXMLParserWrapper; 6 import org.apache.axis2.soap.SOAPHeader; 7 import org.apache.axis2.soap.impl.llom.SOAPConstants; 8 import org.apache.axis2.soap.impl.llom.SOAPHeaderBlockImpl; 9 import org.apache.axis2.soap.impl.llom.SOAPProcessingException; 10 11 29 public class SOAP11HeaderBlockImpl extends SOAPHeaderBlockImpl { 30 34 public SOAP11HeaderBlockImpl(String localName, OMNamespace ns, SOAPHeader parent) throws SOAPProcessingException { 35 super(localName, ns, parent); 36 checkParent(parent); 37 } 38 39 47 public SOAP11HeaderBlockImpl(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) { 48 super(localName, ns, parent, builder); 49 } 50 51 52 protected void checkParent(OMElement parent) throws SOAPProcessingException { 53 if (!(parent instanceof SOAP11HeaderImpl)) { 54 throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Body as the parent. But received some other implementation"); 55 } 56 } 57 58 public void setRole(String roleURI) { 59 setAttribute(SOAP11Constants.ATTR_ACTOR, roleURI, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); 60 61 } 62 63 public String getRole() { 64 return getAttribute(SOAP11Constants.ATTR_ACTOR, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); 65 } 66 67 public void setMustUnderstand(boolean mustUnderstand) { 68 setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand ? "1" : "0", SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); 69 } 70 71 public void setMustUnderstand(String mustUnderstand) throws SOAPProcessingException { 72 if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) { 73 setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); 74 } else { 75 throw new SOAPProcessingException("mustUndertand should be one of \"true\", \"false\", \"0\" or \"1\" "); 76 } 77 } 78 79 87 public boolean getMustUnderstand() throws SOAPProcessingException { 88 String mustUnderstand = ""; 89 if ((mustUnderstand = getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) 90 != null) { 91 if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_1.equalsIgnoreCase(mustUnderstand)) { 92 return true; 93 } else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_0.equalsIgnoreCase(mustUnderstand)) { 94 return false; 95 } else { 96 throw new SOAPProcessingException("Invalid value found in mustUnderstand value of " + this.getLocalName() + " header block"); 97 } 98 } 99 return false; 100 101 } 102 } 103 | Popular Tags |