}
private SecurityPolicy getInboundFaultPolicy(SOAPMessage msg) {
if (cachedOperation != null) {
WSDLOperation operation = cachedOperation.getOperation();
SecurityPolicyHolder sph = inMessagePolicyMap.get(cachedOperation);
try {
SOAPBody body = msg.getSOAPBody();
NodeList nodes = body.getElementsByTagName("detail");
if (nodes.getLength() == 0) {
nodes = body.getElementsByTagNameNS(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Detail");
}
if(nodes.getLength() == 0) {
nodes = body.getElementsByTagNameNS(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "detail");
}
if(nodes.getLength() == 0) {
return sph.getMessagePolicy();
}
if (nodes.getLength() > 0) {
Node node = nodes.item(0);
Node faultNode = node.getFirstChild();
while (faultNode != null && faultNode.getNodeType() != Node.ELEMENT_NODE)
faultNode = faultNode.getNextSibling(); //fix for bug #1487
if (faultNode == null) {
return new MessagePolicy();
}
final String uri = faultNode.getNamespaceURI();
final QName faultDetail;
if (uri != null && uri.length() > 0) {
faultDetail = new QName(uri, faultNode.getLocalName());
} else {
faultDetail = new QName(faultNode.getLocalName());
}
WSDLFault fault = operation.getFault(faultDetail);
SecurityPolicyHolder faultPolicyHolder = sph.getFaultPolicy(fault);
SecurityPolicy faultPolicy = (faultPolicyHolder == null) ? new MessagePolicy() : faultPolicyHolder.getMessagePolicy();
return faultPolicy;
}
} catch (SOAPException sx) {
//sx.printStackTrace();
//log error