use of javax.xml.soap.SOAPFault in project OpenAM by OpenRock.
the class SAMLSOAPReceiver method FormSOAPError.
/**
* This method forms a SOAP Fault and puts it in the SOAP Message's
* Body.
*/
private SOAPMessage FormSOAPError(HttpServletResponse resp, String faultCode, String faultString, String detail) {
SOAPMessage msg = null;
SOAPEnvelope envelope = null;
SOAPFault sf = null;
SOAPBody body = null;
SOAPElement se = null;
try {
msg = msgFactory.createMessage();
envelope = msg.getSOAPPart().getEnvelope();
body = envelope.getBody();
sf = body.addFault();
Name qName = envelope.createName(faultCode, null, SOAPConstants.URI_NS_SOAP_ENVELOPE);
sf.setFaultCode(qName);
sf.setFaultString(SAMLUtils.bundle.getString(faultString));
if ((detail != null) && !(detail.length() == 0)) {
Detail det = sf.addDetail();
se = (SOAPElement) det.addDetailEntry(envelope.createName("Problem"));
se.addAttribute(envelope.createName("details"), SAMLUtils.bundle.getString(detail));
}
} catch (SOAPException e) {
SAMLUtils.debug.error("FormSOAPError:", e);
String[] data = { SAMLUtils.bundle.getString("soapFaultError") };
LogUtils.error(java.util.logging.Level.INFO, LogUtils.SOAP_FAULT_ERROR, data);
resp.setStatus(resp.SC_INTERNAL_SERVER_ERROR);
}
return msg;
}
use of javax.xml.soap.SOAPFault in project OpenAM by OpenRock.
the class FSSOAPService method formSOAPError.
/**
* Forms a SOAP Fault and puts it in the SOAP Message's Body.
*
* @param faultcode fault code to be set in SOAPMEssage
* @param faultString fault string
* @param detail the details of the fault condition
* @return <code>SOAPMessage</code> containing the SOAP fault
*/
public SOAPMessage formSOAPError(String faultcode, String faultString, String detail) {
SOAPMessage msg = null;
SOAPEnvelope envelope = null;
SOAPFault sf = null;
SOAPBody body = null;
SOAPElement se = null;
try {
msg = fac.createMessage();
envelope = msg.getSOAPPart().getEnvelope();
body = envelope.getBody();
sf = body.addFault();
Name qname = envelope.createName(faultcode, null, IFSConstants.SOAP_URI);
sf.setFaultCode(qname);
sf.setFaultString(FSUtils.bundle.getString(faultString));
if ((detail != null) && !(detail.length() == 0)) {
Detail det = sf.addDetail();
se = (SOAPElement) det.addDetailEntry(envelope.createName("Problem"));
se.addAttribute(envelope.createName("details"), FSUtils.bundle.getString(detail));
}
} catch (SOAPException e) {
FSUtils.debug.error("FSSOAPService.formSOAPError:", e);
return null;
}
return msg;
}
use of javax.xml.soap.SOAPFault in project wildfly by wildfly.
the class EJBEndpoint method helloError.
public String helloError(String input) {
try {
SOAPFault fault = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createFault(input, SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
fault.setFaultActor("mr.actor");
fault.addDetail().addChildElement("test");
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException"));
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "OperatorNotFound"));
throw new SOAPFaultException(fault);
} catch (SOAPException ex) {
ex.printStackTrace();
}
return "Failure!";
}
Aggregations