Search in sources :

Example 1 with Calculator

use of com.example.calculator.Calculator in project Payara by payara.

the class SOAPWebConsumer method addUsingSOAPConsumer.

private void addUsingSOAPConsumer() {
    com.example.calculator.Calculator port = null;
    port = service.getCalculatorPort();
    // Get Stub
    BindingProvider stub = (BindingProvider) port;
    String endpointURI = "http://localhost:12011/calculatorendpoint";
    stub.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURI);
    String failedMsg = null;
    try {
        System.out.println("\nInvoking throwRuntimeException");
        port.throwRuntimeException("bhavani");
    } catch (Exception ex) {
        System.out.println(ex);
        if (!(ex instanceof SOAPFaultException) || !(ex.getMessage().equals("java.lang.RuntimeException: Calculator :: Threw Runtime Exception"))) {
            failedMsg = "port.throwRuntimeException() did not receive RuntimeException 'Calculator :: Threw Runtime Exception'";
        }
    }
    try {
        System.out.println("\nInvoking throwApplicationException");
        port.throwApplicationException("bhavani");
    } catch (Exception ex) {
        System.out.println(ex);
        if (!(ex instanceof com.example.calculator.Exception_Exception)) {
            failedMsg = "port.throwApplicationException() did not throw ApplicationException";
        }
    }
    if (failedMsg != null) {
        stat.addStatus(testId, stat.FAIL);
    } else {
        stat.addStatus(testId, stat.PASS);
    }
}
Also used : Calculator(com.example.calculator.Calculator) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) BindingProvider(javax.xml.ws.BindingProvider) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Aggregations

Calculator (com.example.calculator.Calculator)1 BindingProvider (javax.xml.ws.BindingProvider)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1