}
String roleValue = headerBlock.getRole();
boolean mustUnderstand = headerBlock.getMustUnderstand();
String elementName = headerBlock.getLocalName();
OMNamespace headerBlockNamespace = headerBlock.getNamespace();
if (elementName.equals(REQUEST_HEADERBLOCK_NAME)) {
if (roleValue == null || roleValue.equals(SAMPLE_ROLE + "/" + ROLE_BY_B) || roleValue.equals(SOAP12_ROLE + "/" + ULTIMATERECEIVER_ROLE) ||
roleValue.equals(SOAP12_ROLE + "/" + NEXT_ROLE)) {
headerBlock.setLocalName(RESPONSE_HEADERBLOCK_NAME);
if (attributePresent)
headerBlock.removeAttribute((OMAttribute) headerBlock.getAttributes().next());
headerBlockPresent = new Integer(1);
msgContext.getOperationContext().setProperty("HEADER_BLOCK_PRESENT", headerBlockPresent, true);
headerAdd.addChild(headerBlock);
msgContext.getOperationContext().setProperty("HEADER_BLOCK", headerAdd, true);
}
} else {
if (roleValue == null || roleValue.equals(SAMPLE_ROLE + "/" + ROLE_BY_B) || roleValue.equals(SAMPLE_ROLE + "/" + ROLE_BY_C) ||
roleValue.equals(SOAP12_ROLE + "/" + ULTIMATERECEIVER_ROLE) || roleValue.equals(SOAP12_ROLE + "/" + NEXT_ROLE)) {
if (mustUnderstand) {
SOAPBody body = factory.getDefaultEnvelope().getBody();
if (attributePresent && attributeNS.getName() == "http://schemas.xmlsoap.org/soap/envelope/") {
} else {
try {
SOAPFault fault = factory.createSOAPFault(body);
SOAPFaultCode code = factory.createSOAPFaultCode(fault);
SOAPFaultValue value = factory.createSOAPFaultValue(code);
value.setText("env:MustUnderstand");
SOAPFaultReason reason = factory.createSOAPFaultReason(fault);
SOAPFaultText text = factory.createSOAPFaultText(reason);
text.setLang("en-US");
text.setText("Header not understood");
reason.setSOAPText(text);
//fault.setReason(reason);
if (roleValue != null && roleValue.equals(SAMPLE_ROLE + "/" + ROLE_BY_B)) {
SOAPFaultNode node = factory.createSOAPFaultNode(fault);
node.setNodeValue(SAMPLE_ROLE + "/" + ROLE_BY_B);
SOAPFaultRole role = factory.createSOAPFaultRole(fault);
role.setRoleValue(SAMPLE_ROLE + "/" + ROLE_BY_B);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME, node);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME, role);
}
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, code);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, reason);
} catch (SOAPProcessingException e) {
throw new AxisFault(e);
}
headerBlock.discard();
SOAPHeaderBlock newHeaderBlock = null;
try {
newHeaderBlock = envelope.getHeader().addHeaderBlock("NotUnderstood", envelope.getNamespace());
newHeaderBlock.declareNamespace(headerBlockNamespace);
newHeaderBlock.addAttribute("qname", headerBlockNamespace.getName() + ":" + elementName, null);
} catch (SOAPProcessingException e) {
//e.printStackTrace();
}
headerBlockPresent = new Integer(1);
msgContext.getOperationContext().setProperty("HEADER_BLOCK_PRESENT", headerBlockPresent, true);