Search in sources :

Example 26 with ProtocolException

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

the class FaultImpl method echo.

public java.lang.String echo(java.lang.String type) throws Fault1Exception, Fault2Exception, Fault3Exception, Fault4Exception {
    if (type.equals("Fault1")) {
        FooException fault = new FooException();
        fault.setVarInt(1);
        fault.setVarString("1");
        fault.setVarFloat(1);
        System.out.println("Throwing Fault1Exception");
        throw new Fault1Exception("Fault1 message", fault);
    } else if (type.equals("Fault1-SOAPFaultException")) {
        FooException fault = new FooException();
        fault.setVarInt(1);
        fault.setVarString("1");
        fault.setVarFloat(1);
        System.out.println("Throwing Fault1Exception with Cause");
        throw new Fault1Exception("Fault1 message", fault, createSOAPFaultException());
    } else if (type.equals("Fault2")) {
        String fault = "fault2";
        System.out.println("Throwing Fault2Exception");
        throw new Fault2Exception("Fault2 message", fault);
    } else if (type.equals("Fault3")) {
        Integer fault = Integer.valueOf("1");
        System.out.println("Throwing Fault3Exception");
        throw new Fault3Exception("Fault3 message", fault);
    } else if (type.equals("Fault4")) {
        Fault4 fault = new Fault4();
        fault.setMessage("fault4");
        fault.setCount(1);
        System.out.println("Throwing Fault4Exception");
        throw new Fault4Exception("Fault4 message", fault);
    } else if (type.equals("SOAPFaultException")) {
        throw createSOAPFaultException();
    } else if (type.equals("NullPointerException")) {
        Object o = null;
        // generate NPE
        o.hashCode();
    } else if (type.equals("ProtocolException")) {
        throw new ProtocolException();
    } else if (type.equals("ProtocolException2")) {
        throw new ProtocolException("FaultImpl");
    } else if (type.equals("multipleDetails")) {
        createSaajBug();
    } else if (type.equals("nullBean")) {
        throw new Fault2Exception(null, null, new WebServiceException("User exception!"));
    } else if (type.equals("echo")) {
        // used in MU test
        return "echo";
    }
    return "Unknown fault: " + type;
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) WebServiceException(jakarta.xml.ws.WebServiceException)

Example 27 with ProtocolException

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

the class FaultImpl method echo.

public java.lang.String echo(java.lang.String type) throws Fault1Exception, Fault2Exception, Fault3Exception, Fault4Exception {
    if (type.equals("Fault1")) {
        FooException fault = new FooException();
        fault.setVarInt(1);
        fault.setVarString("1");
        fault.setVarFloat(1);
        System.out.println("Throwing Fault1Exception");
        throw new Fault1Exception("Fault1 message", fault);
    } else if (type.equals("Fault1-SOAPFaultException")) {
        FooException fault = new FooException();
        fault.setVarInt(1);
        fault.setVarString("1");
        fault.setVarFloat(1);
        System.out.println("Throwing Fault1Exception with Cause");
        throw new Fault1Exception("Fault1 message", fault, createSOAPFaultException());
    } else if (type.equals("Fault2")) {
        String fault = "fault2";
        System.out.println("Throwing Fault2Exception");
        throw new Fault2Exception("Fault2 message", fault);
    } else if (type.equals("Fault3")) {
        Integer fault = Integer.valueOf("1");
        System.out.println("Throwing Fault3Exception");
        throw new Fault3Exception("Fault3 message", fault);
    } else if (type.equals("Fault4")) {
        Fault4 fault = new Fault4();
        fault.setMessage("fault4");
        fault.setCount(1);
        System.out.println("Throwing Fault4Exception");
        throw new Fault4Exception("Fault4 message", fault);
    } else if (type.equals("SOAPFaultException")) {
        throw createSOAPFaultException();
    } else if (type.equals("NullPointerException")) {
        Object o = null;
        // generate NPE
        o.hashCode();
    } else if (type.equals("ProtocolException")) {
        throw new ProtocolException();
    } else if (type.equals("ProtocolException2")) {
        throw new ProtocolException("FaultImpl");
    } else if (type.equals("multipleDetails")) {
        createSaajBug();
    } else if (type.equals("nullBean")) {
        throw new Fault2Exception(null, null, new WebServiceException("User exception!"));
    } else if (type.equals("echo")) {
        // used in MU test
        return "echo";
    }
    return "Unknown fault: " + type;
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) WebServiceException(jakarta.xml.ws.WebServiceException)

Example 28 with ProtocolException

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

the class FaultImpl method echo.

public java.lang.String echo(java.lang.String type) throws Fault1Exception, Fault2Exception, Fault3Exception, Fault4Exception {
    if (type.equals("Fault1")) {
        FooException fault = new FooException();
        fault.setVarInt(1);
        fault.setVarString("1");
        fault.setVarFloat(1);
        System.out.println("Throwing Fault1Exception");
        throw new Fault1Exception("Fault1 message", fault);
    } else if (type.equals("Fault1-SOAPFaultException")) {
        FooException fault = new FooException();
        fault.setVarInt(1);
        fault.setVarString("1");
        fault.setVarFloat(1);
        System.out.println("Throwing Fault1Exception with Cause");
        throw new Fault1Exception("Fault1 message", fault, createSOAPFaultException(null, "Fault1 message"));
    } else if (type.equals("Fault2")) {
        String fault = "fault2";
        System.out.println("Throwing Fault2Exception");
        throw new Fault2Exception("Fault2 message", fault);
    } else if (type.equals("Fault3")) {
        Integer fault = Integer.valueOf("1");
        System.out.println("Throwing Fault3Exception");
        throw new Fault3Exception("Fault3 message", fault);
    } else if (type.equals("Fault4")) {
        Fault4 fault = new Fault4();
        fault.setMessage("fault4");
        fault.setCount(1);
        System.out.println("Throwing Fault4Exception");
        throw new Fault4Exception("Fault4 message", fault);
    } else if (type.equals("SOAPFaultException")) {
        throw createSOAPFaultException(null, "SOAPFaultException");
    } else if (type.equals("NullPointerException")) {
        Object o = null;
        o.hashCode();
    } else if (type.equals("ProtocolException")) {
        throw new ProtocolException();
    } else if (type.equals("ProtocolException2")) {
        throw new ProtocolException("FaultImpl");
    // } else if (type.equals("RemoteExceptionWithSFECause")) {
    // throw new RemoteException("RemoteExceptionWithSFECause", createSOAP12FaultException(null,
    // "SOAP12FaultException Test"));
    // } else if (type.equals("RemoteExceptionWithSFECause2")) {
    // SOAP12FaultException soapFault = createSOAP12FaultException(new QName("SoapFault"),
    // "Endpoint encountered an error");
    // throw new RemoteException("RemoteExceptionWithSFECause2", soapFault);
    } else if (type.equals("echo")) {
        // used in MU test
        return "echo";
    }
    return "Unknown fault: " + type;
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException)

Example 29 with ProtocolException

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

the class SOAPTestHandler method handleMessage.

public boolean handleMessage(SOAPMessageContext smc) {
    try {
        SOAPMessage message = smc.getMessage();
        SOAPBody body = message.getSOAPBody();
        SOAPElement paramElement = (SOAPElement) body.getFirstChild().getFirstChild();
        int number = Integer.parseInt(paramElement.getValue());
        if (number == THROW_RUNTIME_EXCEPTION) {
            throw new RuntimeException("EXPECTED EXCEPTION");
        } else if (number == THROW_PROTOCOL_EXCEPTION) {
            throw new ProtocolException("EXPECTED EXCEPTION");
        } else if (number == THROW_SOAPFAULT_EXCEPTION) {
        // todo
        }
        paramElement.setValue(String.valueOf(++number));
    } catch (SOAPException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    return true;
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) SOAPBody(jakarta.xml.soap.SOAPBody) SOAPException(jakarta.xml.soap.SOAPException) SOAPElement(jakarta.xml.soap.SOAPElement) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 30 with ProtocolException

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

the class EndToEndErrorTest method testServerInboundRuntimeException2.

/*
     * Have one of the server handlers throw a runtime
     * exception and check that the proper methods are called.
     * This test uses a protocol handler.
     */
public void testServerInboundRuntimeException2() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    // these lines make calls to the server
    reportStub.clearHandlerTracker();
    for (int i = 0; i < numTotalHandlers; i++) {
        reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
    }
    reportStub.setInstruction(SERVER_PREFIX + 2, HA_THROW_RUNTIME_EXCEPTION_INBOUND);
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    try {
        testStub.testInt(3);
        fail("did not receive exception");
    } catch (ProtocolException e) {
    // ok
    }
    // check result
    String[] called = { "4", "2" };
    List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
    assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
    for (int i = 0; i < called.length; i++) {
        assertEquals("did not find expected handler", SERVER_PREFIX + called[i], calledHandlers.get(i));
    }
    // should be no destroyed handlers
    List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
    assertTrue("Should be no destroyed handlers", destroyedHandlers.isEmpty());
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) HandlerTracker(handler.handler_processing.common.HandlerTracker)

Aggregations

ProtocolException (jakarta.xml.ws.ProtocolException)36 WebServiceException (jakarta.xml.ws.WebServiceException)14 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)13 HandlerTracker (fromwsdl.handler.common.HandlerTracker)11 HandlerTracker (handler.handler_processing.common.HandlerTracker)11 TestProtocolException (fromwsdl.handler.common.TestProtocolException)5 TestProtocolException (handler.handler_processing.common.TestProtocolException)5 QName (javax.xml.namespace.QName)4 Message (com.sun.xml.ws.api.message.Message)2 MUHelperHandler (fromwsdl.soap12.fault.client.handlers.MUHelperHandler)2 SOAPBody (jakarta.xml.soap.SOAPBody)2 SOAPElement (jakarta.xml.soap.SOAPElement)2 SOAPException (jakarta.xml.soap.SOAPException)2 SOAPMessage (jakarta.xml.soap.SOAPMessage)2 Node (org.w3c.dom.Node)2 SerializationException (com.sun.xml.ws.encoding.soap.SerializationException)1 JAXBMessage (com.sun.xml.ws.message.jaxb.JAXBMessage)1 CheckedExceptionImpl (com.sun.xml.ws.model.CheckedExceptionImpl)1 DispatchException (com.sun.xml.ws.wsdl.DispatchException)1 ExceptionThrowingHandler (fromwsdl.soap12.fault.client.handlers.ExceptionThrowingHandler)1