Search in sources :

Example 6 with SOAPFault

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;
}
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 7 with SOAPFault

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;
}
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 8 with SOAPFault

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!";
}
Also used : QName(javax.xml.namespace.QName) SOAPException(javax.xml.soap.SOAPException) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Aggregations

SOAPFault (javax.xml.soap.SOAPFault)8 SOAPException (javax.xml.soap.SOAPException)5 Detail (javax.xml.soap.Detail)4 SOAPElement (javax.xml.soap.SOAPElement)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 QName (javax.xml.namespace.QName)3 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)3 SOAPMessage (javax.xml.soap.SOAPMessage)3 Name (javax.xml.soap.Name)2 SOAPBody (javax.xml.soap.SOAPBody)2 URL (java.net.URL)1 WebMethod (javax.jws.WebMethod)1 WebResult (javax.jws.WebResult)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 DetailEntry (javax.xml.soap.DetailEntry)1 SOAPFactory (javax.xml.soap.SOAPFactory)1 Holder (javax.xml.ws.Holder)1 Person (org.apache.camel.wsdl_first.Person)1 PersonService (org.apache.camel.wsdl_first.PersonService)1