soapFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope message = soapFactory.getDefaultFaultEnvelope();
SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason();
soapFaultReason.setText(reason);
message.getBody().getFault().setReason(soapFaultReason);
SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode();
QName qNameSubCode = new QName(CommandBuilderConstants.WSE_EVENTING_NS, subCode,
CommandBuilderConstants.WSE_EVENTING_PREFIX);
soapFaultCode.setText(qNameSubCode);
message.getBody().getFault().setCode(soapFaultCode);
return message;
} else {
soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPEnvelope message = soapFactory.getDefaultFaultEnvelope();
SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail();
soapFaultDetail.setText(detail);
message.getBody().getFault().setDetail(soapFaultDetail);
SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason();
SOAPFaultText soapFaultText = soapFactory.createSOAPFaultText();
soapFaultText.setText(reason);
soapFaultReason.addSOAPText(soapFaultText);
message.getBody().getFault().setReason(soapFaultReason);
SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode();
SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
soapFaultValue.setText(code);
soapFaultCode.setValue(soapFaultValue);
SOAPFaultSubCode soapFaultSubCode = soapFactory.createSOAPFaultSubCode(soapFaultCode);
SOAPFaultValue soapFaultValueSub = soapFactory.createSOAPFaultValue(soapFaultSubCode);
QName qNameSubCode = new QName(CommandBuilderConstants.WSE_EVENTING_NS, subCode,
CommandBuilderConstants.WSE_EVENTING_PREFIX);
soapFaultValueSub.setText(qNameSubCode);
soapFaultSubCode.setValue(soapFaultValueSub);
soapFaultCode.setSubCode(soapFaultSubCode);
message.getBody().getFault().setCode(soapFaultCode);
return message;
}
}