Search in sources :

Example 41 with SOAPFaultException

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

the class Soap12ClientServerTest method testFaultMessage.

@Test
public void testFaultMessage() throws Exception {
    Greeter greeter = getGreeter();
    try {
        greeter.sayHi();
        fail("Should throw Exception!");
    } catch (SOAPFaultException ex) {
        assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>", ex.getMessage());
        StackTraceElement[] element = ex.getCause().getStackTrace();
        assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl12", element[0].getClassName());
    }
}
Also used : Greeter(org.apache.hello_world_soap12_http.Greeter) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 42 with SOAPFaultException

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

the class CircuitBreakerFailoverTest method testWithNoAlternativeEndpoints.

@Test
public void testWithNoAlternativeEndpoints() throws Exception {
    final Greeter g = getGreeter(REPLICA_E);
    try {
        g.greetMe("fred");
        fail("Expecting communication exception");
    } catch (WebServiceException ex) {
        assertThat(ex.getMessage(), equalTo("Could not send Message."));
    }
    try {
        g.greetMe("fred");
        fail("Expecting no alternative endpoints exception");
    } catch (SOAPFaultException ex) {
        assertThat(ex.getMessage(), equalTo("None of alternative addresses are available at the moment"));
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Greeter(org.apache.cxf.greeter_control.Greeter) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 43 with SOAPFaultException

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

the class WSAClientServerTest method testDuplicateHeaders.

// CXF-3456
@Test
public void testDuplicateHeaders() throws Exception {
    URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
    assertNotNull("WSDL is null", wsdl);
    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    QName portName = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersPort");
    Dispatch<SOAPMessage> disp = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature(false, false));
    disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
    InputStream msgIns = getClass().getResourceAsStream("./duplicate-wsa-header-msg.xml");
    String msg = new String(IOUtils.readBytesFromStream(msgIns));
    msg = msg.replaceAll("$PORT", PORT);
    ByteArrayInputStream bout = new ByteArrayInputStream(msg.getBytes());
    SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, bout);
    assertNotNull(soapReqMsg);
    try {
        disp.invoke(soapReqMsg);
        fail("SOAPFaultFxception is expected");
    } catch (SOAPFaultException ex) {
        assertTrue("WSA header exception is expected", ex.getMessage().indexOf("A header representing a Message Addressing") > -1);
    }
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) QName(javax.xml.namespace.QName) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL) Test(org.junit.Test)

Example 44 with SOAPFaultException

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

the class WSAFromJavaTest method testAddNumbersJaxWsContext.

@Test
public void testAddNumbersJaxWsContext() throws Exception {
    ByteArrayOutputStream output = setupOutLogging();
    AddNumberImpl port = getPort();
    BindingProvider bp = (BindingProvider) port;
    java.util.Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, "cxf");
    try {
        assertEquals(3, port.addNumbers(1, 2));
        fail("Should have thrown an ActionNotSupported exception");
    } catch (SOAPFaultException ex) {
    // expected
    }
    assertLogContains(output.toString(), "//wsa:Action", "cxf");
    assertTrue(output.toString(), output.toString().indexOf("SOAPAction=\"cxf\"") != -1);
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BindingProvider(javax.xml.ws.BindingProvider) Test(org.junit.Test)

Example 45 with SOAPFaultException

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

the class WSAFromWSDLTest method testNonAnonToAnon.

@Test
public void testNonAnonToAnon() throws Exception {
    try (AddNumbersPortTypeProxy port = getPort()) {
        port.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/addAnon");
        AddressingProperties maps = new AddressingProperties();
        EndpointReferenceType ref = new EndpointReferenceType();
        AttributedURIType add = new AttributedURIType();
        add.setValue("http://localhost:" + INVALID_PORT + "/not/a/real/url");
        ref.setAddress(add);
        maps.setReplyTo(ref);
        maps.setFaultTo(ref);
        port.getRequestContext().put("javax.xml.ws.addressing.context", maps);
        try {
            port.addNumbers3(-1, 2);
        } catch (SOAPFaultException e) {
            assertTrue(e.getFault().getFaultCode().contains("OnlyAnonymousAddressSupported"));
        }
    }
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) AddNumbersPortTypeProxy(org.apache.cxf.systest.ws.addr_feature.AddNumbersService.AddNumbersPortTypeProxy) Test(org.junit.Test)

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