use of javax.xml.soap.Detail in project quickstarts by jboss-switchyard.
the class ReverseService method reverse.
@POST
@Path("/")
@WebMethod(action = "urn:switchyard-quickstart:camel-soap-proxy:1.0")
@WebResult(name = "text")
public String reverse(@WebParam(name = "text") String text) throws Exception {
if (text.equals("fault")) {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault sf = factory.createFault("myfaultstring", new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server"));
sf.setFaultActor("myFaultActor");
Detail d = sf.addDetail();
QName entryName = new QName("urn:switchyard-quickstart:camel-soap-proxy:1.0", "order", "PO");
DetailEntry entry = d.addDetailEntry(entryName);
QName name = new QName("urn:switchyard-quickstart:camel-soap-proxy:1.0", "symbol");
SOAPElement symbol = entry.addChildElement(name);
symbol.addTextNode("SUNW");
throw new SOAPFaultException(sf);
}
return new StringBuilder(text).reverse().toString();
}
use of javax.xml.soap.Detail in project OpenAM by OpenRock.
the class SOAPCommunicator method createSOAPFault.
/**
* Forms a SOAP Fault and puts it in the SOAP Message Body.
*
* @param faultCode Fault code.
* @param faultString Fault string.
* @param detail Fault details.
* @return SOAP Fault in the SOAP Message Body or null if unable to generate the message.
*/
public SOAPMessage createSOAPFault(final String faultCode, final String faultString, final String detail) {
try {
SOAPMessage message = messageFactory.createMessage();
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
SOAPFault fault = envelope.getBody().addFault();
fault.setFaultCode(envelope.createName(faultCode, null, SOAPConstants.URI_NS_SOAP_ENVELOPE));
fault.setFaultString(SAML2Utils.bundle.getString(faultString));
if (StringUtils.isNotEmpty(detail)) {
Detail faultDetail = fault.addDetail();
SOAPElement faultDetailEntry = (SOAPElement) faultDetail.addDetailEntry(envelope.createName("Problem"));
faultDetailEntry.addAttribute(envelope.createName("details"), SAML2Utils.bundle.getString(detail));
}
return message;
} catch (SOAPException e) {
debug.error("createSOAPFault:", e);
return null;
}
}
use of javax.xml.soap.Detail 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.Detail 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;
}
Aggregations