Search in sources :

Example 96 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.

the class SoapJmsSpecTest method testBindingVersionError.

@Test
public void testBindingVersionError() throws Exception {
    QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
    QName portName = new QName(SERVICE_NS, "GreeterPort");
    URL wsdl = getWSDLURL(WSDL);
    JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
    JMSGreeterPortType greeter = markForClose(service.getPort(portName, JMSGreeterPortType.class, cff));
    BindingProvider bp = (BindingProvider) greeter;
    Map<String, Object> requestContext = bp.getRequestContext();
    JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
    requestHeader.setSOAPJMSBindingVersion("0.3");
    requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
    try {
        greeter.greetMe("Milestone-");
        Assert.fail("Should have thrown a fault");
    } catch (SOAPFaultException ex) {
        Assert.assertTrue(ex.getMessage().contains("0.3"));
        Map<String, Object> responseContext = bp.getResponseContext();
        JMSMessageHeadersType responseHdr = (JMSMessageHeadersType) responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
        if (responseHdr == null) {
            Assert.fail("response Header should not be null");
        }
        Assert.assertTrue(responseHdr.isSOAPJMSIsFault());
    }
}
Also used : QName(javax.xml.namespace.QName) JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) BindingProvider(javax.xml.ws.BindingProvider) JMSGreeterService(org.apache.cxf.jms_greeter.JMSGreeterService) JMSGreeterPortType(org.apache.cxf.jms_greeter.JMSGreeterPortType) Map(java.util.Map) URL(java.net.URL) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Example 97 with SOAPFaultException

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

SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)97 Test (org.junit.Test)47 QName (javax.xml.namespace.QName)33 URL (java.net.URL)22 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 Test (org.testng.annotations.Test)21 Holder (javax.xml.ws.Holder)19 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)17 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)17 SOAPFault (javax.xml.soap.SOAPFault)17 SOAPException (javax.xml.soap.SOAPException)16 Service (javax.xml.ws.Service)11 WebServiceException (javax.xml.ws.WebServiceException)9 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)9 SOAPMessage (javax.xml.soap.SOAPMessage)8 SoapFault (org.apache.cxf.binding.soap.SoapFault)8 Bus (org.apache.cxf.Bus)6 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)6 Fault (org.apache.cxf.interceptor.Fault)6