Search in sources :

Example 1 with SOAPFault

use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.

the class MUTube method createMUSOAPFaultException.

/**
 * @return SOAPfaultException with SOAPFault representing the MustUnderstand SOAP Fault.
 *         notUnderstoodHeaders are added in the fault detail.
 */
final SOAPFaultException createMUSOAPFaultException(Set<QName> notUnderstoodHeaders) {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault(MUST_UNDERSTAND_FAULT_MESSAGE_STRING, soapVersion.faultCodeMustUnderstand);
        fault.setFaultString("MustUnderstand headers:" + notUnderstoodHeaders + " are not understood");
        return new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) SOAPException(jakarta.xml.soap.SOAPException) SOAPFault(jakarta.xml.soap.SOAPFault) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 2 with SOAPFault

use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.

the class jaxws413Test method test1.

public void test1() throws SOAPException, IOException {
    SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
    fault.setFaultCode(new QName("http://foo/bar", "mycode", "myprefix"));
    fault.setFaultString("Some exception");
    Detail detail = fault.addDetail();
    detail.addDetailEntry(new QName("http://foo/bar", "soap11detail"));
    Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(SOAPVersion.SOAP_11, fault);
    SOAPMessage sm = faultMsg.readAsSOAPMessage();
    Detail det = sm.getSOAPBody().getFault().getDetail();
    Iterator iter = det.getDetailEntries();
    assertTrue(iter.hasNext());
    Element item = (Element) iter.next();
    assertEquals(item.getNamespaceURI(), "http://foo/bar");
    assertEquals(item.getLocalName(), "soap11detail");
}
Also used : Message(com.sun.xml.ws.api.message.Message) SOAPMessage(jakarta.xml.soap.SOAPMessage) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) SOAPFault(jakarta.xml.soap.SOAPFault) SOAPMessage(jakarta.xml.soap.SOAPMessage) Detail(jakarta.xml.soap.Detail)

Example 3 with SOAPFault

use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.

the class WsaTubeHelper method createInvalidAddressingHeaderFault.

public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
    QName name = e.getProblemHeader();
    QName subsubcode = e.getSubsubcode();
    QName subcode = av.invalidMapTag;
    String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);
    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getInvalidMapDetail(name, fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }
        fault.setFaultString(faultstring);
        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) SOAPException(jakarta.xml.soap.SOAPException) SOAPFault(jakarta.xml.soap.SOAPFault) SOAPFactory(jakarta.xml.soap.SOAPFactory)

Example 4 with SOAPFault

use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.

the class WsaTubeHelper method newMapRequiredFault.

public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
    QName subcode = addVer.mapRequiredTag;
    QName subsubcode = addVer.mapRequiredTag;
    String faultstring = addVer.getMapRequiredText();
    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }
        fault.setFaultString(faultstring);
        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) SOAPException(jakarta.xml.soap.SOAPException) SOAPFault(jakarta.xml.soap.SOAPFault) SOAPFactory(jakarta.xml.soap.SOAPFactory)

Example 5 with SOAPFault

use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.

the class SOAP12Fault method getProtocolException.

protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_12.getSOAPFactory().createFault();
        if (reason != null) {
            for (TextType tt : reason.texts()) {
                fault.setFaultString(tt.getText());
            }
        }
        if (code != null) {
            fault.setFaultCode(code.getValue());
            fillFaultSubCodes(fault, code.getSubcode());
        }
        if (detail != null && detail.getDetail(0) != null) {
            jakarta.xml.soap.Detail detail = fault.addDetail();
            for (Node obj : this.detail.getDetails()) {
                Node n = fault.getOwnerDocument().importNode(obj, true);
                detail.appendChild(n);
            }
        }
        if (node != null) {
            fault.setFaultNode(node);
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) Node(org.w3c.dom.Node) SOAPException(jakarta.xml.soap.SOAPException) SOAPFault(jakarta.xml.soap.SOAPFault)

Aggregations

SOAPFault (jakarta.xml.soap.SOAPFault)45 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)21 QName (javax.xml.namespace.QName)16 SOAPException (jakarta.xml.soap.SOAPException)12 WebServiceException (jakarta.xml.ws.WebServiceException)11 SOAPMessage (jakarta.xml.soap.SOAPMessage)9 HandlerTracker (fromwsdl.handler.common.HandlerTracker)8 HandlerTracker (handler.handler_processing.common.HandlerTracker)8 Detail (jakarta.xml.soap.Detail)7 Message (com.sun.xml.ws.api.message.Message)5 SOAPBody (jakarta.xml.soap.SOAPBody)5 SOAPFactory (jakarta.xml.soap.SOAPFactory)5 Element (org.w3c.dom.Element)5 SOAPElement (jakarta.xml.soap.SOAPElement)3 InvalidAddressingHeaderException (com.sun.xml.ws.addressing.model.InvalidAddressingHeaderException)2 WSService (com.sun.xml.ws.api.WSService)2 OneWayFeature (com.sun.xml.ws.api.addressing.OneWayFeature)2 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)2 FaultDetailHeader (com.sun.xml.ws.message.FaultDetailHeader)2 Iterator (java.util.Iterator)2