Search in sources :

Example 96 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);
}
Also used : Message(com.sun.xml.ws.api.message.Message) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 97 with SOAPFaultException

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

the class EchoClientTest method test1193.

public void test1193() throws Exception {
    try {
        SOAPMessage response = invoke12(createDispatchWithWSDLWithoutAddressing(), MESSAGES.getReplyToRefpsEchoMessage(), S12_NS, getAddress(), ECHO_IN_ACTION, "test1193");
        fail("SOAPFaultException must be thrown");
    } catch (SOAPFaultException e) {
        assertNotNull(e.getFault());
        SOAPFault f = e.getFault();
        assertEquals(new QName("http://schemas.xmlsoap.org/soap/envelope/", "VersionMismatch"), f.getFaultCodeAsQName());
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) SOAPFault(jakarta.xml.soap.SOAPFault) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 98 with SOAPFaultException

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

the class HelloLiteralTest method testMustUnderstand1.

/*
     * MU test here for soap 1.1. Test uses a simple handler
     * on client side to test service with no handlers.
     */
public void testMustUnderstand1() throws Exception {
    String next_1_1 = "http://schemas.xmlsoap.org/soap/actor/next";
    try {
        // clear handlers (should be none) and add helper handler
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
        MUHelperHandler handler = new MUHelperHandler();
        ClientServerTestUtil.addHandlerToBinding(handler, (BindingProvider) stub);
        // have handler set header that is ignored
        handler.setMUHeader(new QName("urn:mutest", "someheader"), "notarealactor");
        // make the call
        String arg = "foo";
        Hello_Type req = new Hello_Type();
        req.setArgument(arg);
        HelloResponse response = stub.hello(req);
        assertEquals(arg, response.getArgument());
        // add header that should result in soap fault
        handler.setMUHeader(new QName("urn:mutest", "someheader"), next_1_1);
        // make the call
        try {
            response = stub.hello(req);
            fail("did not receive any exception");
        } catch (ProtocolException e) {
            if (e instanceof SOAPFaultException) {
            // pass
            } else {
                fail("did not receive soap fault, received: " + e.toString());
            }
        } catch (Exception e) {
            fail("did not receive protocol exception. received " + e.toString());
        }
    } finally {
        // always clear the handlers
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
    }
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) QName(javax.xml.namespace.QName) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) MUHelperHandler(fromwsdl.wsdl_hello_lit.client.handlers.MUHelperHandler) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 99 with SOAPFaultException

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

the class HandlerClient method testServerRtException1.

public void testServerRtException1() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    tracker.clearAll();
    Hello stub = createStub();
    ReportService report = createReportStub();
    report.clearHandlerTracker();
    try {
        int bar = stub.hello(SERVER_THROW_RUNTIME_EXCEPTION);
        assert (false);
    } catch (SOAPFaultException e) {
        // as expected.
        System.out.println("ok");
    }
    List<String> expClientCalled = Arrays.asList(new String[] { "client1", "client1_FAULT" });
    List<String> gotClientCalled = tracker.getCalledHandlers();
    assertTrue(ERR_CLIENT_CALLED_HANDLERS, checkEqual(expClientCalled, gotClientCalled));
    List<String> expServerCalled = Arrays.asList(new String[] { "server2", "server2_FAULT" });
    List<String> gotServerCalled = report.getReport(REPORT_CALLED_HANDLERS);
    assertTrue(ERR_SERVER_CALLED_HANDLERS, checkEqual(expServerCalled, gotServerCalled));
    List<String> expClientClosed = Arrays.asList(new String[] { "client1" });
    List<String> gotClientClosed = tracker.getClosedHandlers();
    assertTrue(ERR_CLIENT_CLOSED_HANDLERS, checkEqual(expClientClosed, gotClientClosed));
    List<String> expServerClosed = Arrays.asList(new String[] { "server2" });
    List<String> gotServerClosed = report.getReport(REPORT_CLOSED_HANDLERS);
    assertTrue(ERR_SERVER_CLOSED_HANDLERS, checkEqual(expServerClosed, gotServerClosed));
}
Also used : HandlerTracker(fromwsdl.handler_singlepipe.common.HandlerTracker) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 100 with SOAPFaultException

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

the class HandlerUtil method throwSOAPFaultException.

boolean throwSOAPFaultException(MessageContext context, String name, String direction) {
    // register called first
    registerHandlerCalled(context, name);
    Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if ((outbound == Boolean.TRUE && direction.equals(INBOUND)) || (outbound == Boolean.FALSE && direction.equals(OUTBOUND))) {
        // not the direction we want
        return true;
    }
    if (ignoreReportMessage(context)) {
        return true;
    }
    // random info in soap fault
    try {
        QName faultCode = new QName("uri", "local", "prefix");
        String faultString = "fault";
        String faultActor = "faultActor";
        SOAPFault sf = SOAPFactory.newInstance().createFault(faultString, faultCode);
        sf.setFaultActor(faultActor);
        Detail detail = sf.addDetail();
        Name entryName = SOAPFactory.newInstance().createName("someFaultEntry");
        detail.addDetailEntry(entryName);
        throw new SOAPFaultException(sf);
    } catch (SOAPException e) {
        throw new RuntimeException("Couldn't create SOAPFaultException " + e);
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) QName(javax.xml.namespace.QName)

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