} else {
final InputStream bodyAsStream = method.getResponseBodyAsStream();
try {
Element bodyEl = DOMUtils.parse(bodyAsStream).getDocumentElement();
QName bodyName = new QName(bodyEl.getNamespaceURI(), bodyEl.getNodeName());
Fault faultDef = WsdlUtils.inferFault(opDef, bodyName);
// is this fault bound with ODE extension?
if (!WsdlUtils.isOdeFault(opBinding.getBindingFault(faultDef.getName()))) {
errmsg = "Fault " + bodyName + " is not bound with " + new QName(Namespaces.ODE_HTTP_EXTENSION_NS, "fault") + ". This 500 error will be considered as a failure.";
if (log.isDebugEnabled()) log.debug(errmsg);
odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, HttpClientHelper.prepareDetailsElement(method));
} else {
Part partDef = (Part) faultDef.getMessage().getParts().values().iterator().next();
// build the element to be sent back
Document odeMsg = DOMUtils.newDocument();
Element odeMsgEl = odeMsg.createElementNS(null, "message");
Element partEl = odeMsgEl.getOwnerDocument().createElementNS(null, partDef.getName());
odeMsgEl.appendChild(partEl);
// import the response body
partEl.appendChild(odeMsgEl.getOwnerDocument().importNode(bodyEl, true));
QName faultType = new QName(targetNamespace, faultDef.getName());
Message response = odeMex.createMessage(faultType);
response.setMessage(odeMsgEl);
// extract and set headers
httpMethodConverter.extractHttpResponseHeaders(response, method, faultDef.getMessage(), opBinding.getBindingOutput());
// finally send the fault. We did it!
odeMex.replyWithFault(faultType, response);
}
} catch (Exception e) {