Search in sources :

Example 1 with Detail

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();
}
Also used : QName(javax.xml.namespace.QName) DetailEntry(javax.xml.soap.DetailEntry) SOAPElement(javax.xml.soap.SOAPElement) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFactory(javax.xml.soap.SOAPFactory) Detail(javax.xml.soap.Detail) Path(javax.ws.rs.Path) WebMethod(javax.jws.WebMethod) POST(javax.ws.rs.POST) WebResult(javax.jws.WebResult)

Example 2 with Detail

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;
    }
}
Also used : SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPFault(javax.xml.soap.SOAPFault) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage) Detail(javax.xml.soap.Detail)

Example 3 with Detail

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;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPFault(javax.xml.soap.SOAPFault) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage) Detail(javax.xml.soap.Detail) Name(javax.xml.soap.Name)

Example 4 with Detail

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;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPFault(javax.xml.soap.SOAPFault) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage) Detail(javax.xml.soap.Detail) Name(javax.xml.soap.Name)

Aggregations

Detail (javax.xml.soap.Detail)4 SOAPElement (javax.xml.soap.SOAPElement)4 SOAPFault (javax.xml.soap.SOAPFault)4 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)3 SOAPException (javax.xml.soap.SOAPException)3 SOAPMessage (javax.xml.soap.SOAPMessage)3 Name (javax.xml.soap.Name)2 SOAPBody (javax.xml.soap.SOAPBody)2 WebMethod (javax.jws.WebMethod)1 WebResult (javax.jws.WebResult)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 QName (javax.xml.namespace.QName)1 DetailEntry (javax.xml.soap.DetailEntry)1 SOAPFactory (javax.xml.soap.SOAPFactory)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1