Search in sources :

Example 1 with SOAPFaultException

use of jakarta.xml.ws.soap.SOAPFaultException 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 SOAPFaultException

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

the class SOAPFaultBuilderTest method testCreate11FaultFromSFE.

public void testCreate11FaultFromSFE() throws Exception {
    SOAPFaultException sfe = new SOAPFaultException(FAULT_11);
    Message msg = SOAPFaultBuilder.createSOAPFaultMessage(SOAPVersion.SOAP_11, sfe, SOAPVersion.SOAP_11.faultCodeMustUnderstand);
    verifyDetail(msg);
}
Also used : Message(com.sun.xml.ws.api.message.Message) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) SOAPMessage(jakarta.xml.soap.SOAPMessage) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 3 with SOAPFaultException

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

the class SOAPFaultBuilder1Test method testFault1.

public void testFault1() throws Throwable {
    SOAPMessage msg = SOAPVersion.SOAP_11.getMessageFactory().createMessage(null, new ByteArrayInputStream(fault1.getBytes()));
    SOAPFaultBuilder sfb = SOAPFaultBuilder.create(new SAAJMessage(msg));
    Throwable t = sfb.createException(null);
    assertTrue(t instanceof SOAPFaultException);
    assertTrue(t.getMessage().contains("Client received SOAP Fault from server:"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 4 with SOAPFaultException

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

the class SOAPFaultBuilder1Test method testFault3.

public void testFault3() throws Exception {
    QName sc1 = new QName("http://example.org/1", "one");
    QName sc2 = new QName("http://example.org/2", "two");
    QName sc3 = new QName("http://example.org/3", "three");
    String faultString = "INTERNAL_ERROR";
    QName detailMsg = new QName("DetailMessage");
    String detailValue = "This method is not implemented";
    SOAPFactory fac = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPFault fault = fac.createFault(faultString, SOAPConstants.SOAP_RECEIVER_FAULT);
    fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
    fault.appendFaultSubcode(sc1);
    fault.appendFaultSubcode(sc2);
    fault.appendFaultSubcode(sc3);
    fault.addDetail().addDetailEntry(detailMsg).setTextContent(detailValue);
    Message fm = SOAPFaultBuilder.createSOAPFaultMessage(SOAPVersion.SOAP_12, fault);
    // get the SOAPFault back
    SOAPFaultBuilder sfb = SOAPFaultBuilder.create(fm);
    Throwable ex = sfb.createException(null);
    assertTrue(ex instanceof SOAPFaultException);
    SOAPFaultException sfe = (SOAPFaultException) ex;
    SOAPFault sf = sfe.getFault();
    assertTrue(sf.getFaultString().equals(faultString));
    // compare detail
    Detail detail = sfe.getFault().getDetail();
    assertTrue(detail != null);
    Iterator iter = detail.getDetailEntries();
    assertTrue(iter.hasNext());
    DetailEntry n = (DetailEntry) iter.next();
    assertTrue((n.getNamespaceURI() != null ? n.getNamespaceURI() : "").equals(detailMsg.getNamespaceURI()) && n.getLocalName().equals(detailMsg.getLocalPart()));
    assertEquals(n.getTextContent(), detailValue);
    // compare code and subcodes
    Iterator scs = sf.getFaultSubcodes();
    assertTrue(scs.hasNext());
    QName sc = (QName) scs.next();
    assertTrue(sc.equals(sc1));
    assertTrue(scs.hasNext());
    sc = (QName) scs.next();
    assertTrue(sc.equals(sc2));
    assertTrue(scs.hasNext());
    sc = (QName) scs.next();
    assertTrue(sc.equals(sc3));
}
Also used : Message(com.sun.xml.ws.api.message.Message) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 5 with SOAPFaultException

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

the class DispatchHello method kkktestBad3HelloRequestResponseXML.

// bad namespace- expect SFE
public void kkktestBad3HelloRequestResponseXML() {
    Dispatch dispatch = getDispatchSource();
    Source source = makeStreamSource(bad3helloMsg);
    Source response = makeStreamSource(helloResponse);
    try {
        Object result = dispatch.invoke(source);
        assertTrue(result == null);
        System.out.println("B3HelloRR invoke succeded");
    } catch (Exception e) {
        try {
            assertTrue(e instanceof SOAPFaultException);
            System.out.println("testBad3HelloRequestResponseXML Passed");
        } catch (Exception ex) {
            System.err.println("Expected SOAPFAULTException - got " + ex.getClass().getName());
            System.out.println("testBad3HelloRequestResponseXML FAILED");
            fail("testBad3HelloRequestResponseXML FAILED");
        }
    }
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) Source(javax.xml.transform.Source) MalformedURLException(java.net.MalformedURLException) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Aggregations

SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)105 QName (javax.xml.namespace.QName)28 WebServiceException (jakarta.xml.ws.WebServiceException)27 SOAPFault (jakarta.xml.soap.SOAPFault)21 JAXBException (jakarta.xml.bind.JAXBException)16 Dispatch (jakarta.xml.ws.Dispatch)16 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)14 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)12 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)12 MalformedURLException (java.net.MalformedURLException)12 Source (javax.xml.transform.Source)12 HandlerTracker (fromwsdl.handler.common.HandlerTracker)11 HandlerTracker (handler.handler_processing.common.HandlerTracker)11 AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)10 Message (com.sun.xml.ws.api.message.Message)9 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)9 ProtocolException (jakarta.xml.ws.ProtocolException)9 IOException (java.io.IOException)7 SOAPMessage (jakarta.xml.soap.SOAPMessage)6 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)5