1 package org.apache.axis2.soap.impl.llom.soap12; 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 27 public class SOAP12HeaderBlockImpl extends SOAPHeaderBlockImpl { 28 31 35 public SOAP12HeaderBlockImpl(String localName, OMNamespace ns, SOAPHeader parent) throws SOAPProcessingException { 36 super(localName, ns, parent); 37 checkParent(parent); 38 } 39 40 48 public SOAP12HeaderBlockImpl(String localName, OMNamespace ns, SOAPHeader parent, OMXMLParserWrapper builder) { 49 super(localName, ns, parent, builder); 50 51 } 52 53 protected void checkParent(OMElement parent) throws SOAPProcessingException { 54 if (!(parent instanceof SOAP12HeaderImpl)) { 55 throw new SOAPProcessingException("Expecting SOAP 1.2 implementation of SOAP Body as the parent. But received some other implementation"); 56 } 57 } 58 59 public void setRole(String roleURI) { 60 setAttribute(SOAP12Constants.SOAP_ROLE, roleURI, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 61 } 62 63 public String getRole() { 64 return getAttribute(SOAP12Constants.SOAP_ROLE, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 65 66 } 67 68 public void setMustUnderstand(boolean mustUnderstand) { 69 setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand ? "1" : "0", SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 70 71 } 72 73 public void setMustUnderstand(String mustUnderstand) throws SOAPProcessingException { 74 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)) { 75 setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 76 } else { 77 throw new SOAPProcessingException("mustUndertand should be one of \"true\", \"false\", \"0\" or \"1\" "); 78 } 79 } 80 81 public boolean getMustUnderstand() throws SOAPProcessingException{ 82 String mustUnderstand = ""; 83 if ((mustUnderstand = getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) 84 != null) { 85 if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_1.equalsIgnoreCase(mustUnderstand)) { 86 return true; 87 }else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_0.equalsIgnoreCase(mustUnderstand)) { 88 return false; 89 }else{ 90 throw new SOAPProcessingException("Invalid value found in mustUnderstand value of "+this.getLocalName() + " header block"); 91 } 92 } 93 return false; 94 95 } 96 } 97 | Popular Tags |