Search in sources :

Example 1 with FaultDetail

use of org.apache.hello_world_soap_http.types.FaultDetail in project camel by apache.

the class CamelTransportClientServerTest method testClientInvocation.

@Test
public void testClientInvocation() throws MalformedURLException {
    Client client = new Client("http://localhost:" + port + "/GreeterContext/GreeterPort");
    Greeter port = client.getProxy();
    assertNotNull("The proxy should not be null", port);
    String resp = port.sayHi();
    assertEquals("Get a wrong response ", "Bonjour from EndpointA", resp);
    resp = port.sayHi();
    assertEquals("Get a wrong response ", "Bonjour from EndpointB", resp);
    resp = port.greetMe("Mike");
    assertEquals("Get a wrong response ", "Hello Mike from EndpointA", resp);
    resp = port.greetMe("James");
    assertEquals("Get a wrong response ", "Hello James from EndpointB", resp);
    port.greetMeOneWay(System.getProperty("user.name"));
    try {
        port.pingMe("hello");
        fail("exception expected but none thrown");
    } catch (PingMeFault ex) {
        assertEquals("Wrong exception message received", "PingMeFault raised by server EndpointB", ex.getMessage());
        FaultDetail detail = ex.getFaultInfo();
        assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
        assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
    }
}
Also used : PingMeFault(org.apache.hello_world_soap_http.PingMeFault) Greeter(org.apache.hello_world_soap_http.Greeter) FaultDetail(org.apache.hello_world_soap_http.types.FaultDetail) Test(org.junit.Test)

Example 2 with FaultDetail

use of org.apache.hello_world_soap_http.types.FaultDetail in project camel by apache.

the class Client method invoke.

public void invoke() throws Exception {
    System.out.println("Acquiring router port ...");
    Greeter port = getProxy();
    String resp;
    System.out.println("Invoking sayHi...");
    resp = port.sayHi();
    System.out.println("Server responded with: " + resp);
    System.out.println();
    System.out.println("Invoking greetMe...");
    resp = port.greetMe(System.getProperty("user.name"));
    System.out.println("Server responded with: " + resp);
    System.out.println();
    System.out.println("Invoking greetMeOneWay...");
    port.greetMeOneWay(System.getProperty("user.name"));
    System.out.println("No response from server as method is OneWay");
    System.out.println();
    try {
        System.out.println("Invoking pingMe, expecting exception...");
        port.pingMe("hello");
    } catch (PingMeFault ex) {
        System.out.println("Expected exception: PingMeFault has occurred: " + ex.getMessage());
        FaultDetail detail = ex.getFaultInfo();
        System.out.println("FaultDetail major:" + detail.getMajor());
        System.out.println("FaultDetail minor:" + detail.getMinor());
    }
}
Also used : PingMeFault(org.apache.hello_world_soap_http.PingMeFault) Greeter(org.apache.hello_world_soap_http.Greeter) FaultDetail(org.apache.hello_world_soap_http.types.FaultDetail)

Example 3 with FaultDetail

use of org.apache.hello_world_soap_http.types.FaultDetail in project camel by apache.

the class JmsPrepareResponse method process.

public void process(Exchange exchange) throws Exception {
    Message in = exchange.getIn();
    if ("greetMe".equals(in.getHeader(CxfConstants.OPERATION_NAME))) {
        String request = in.getBody(String.class);
        exchange.getOut().setBody("Hello" + request);
    } else {
        // throw the Exception
        FaultDetail faultDetail = new FaultDetail();
        faultDetail.setMajor((short) 2);
        faultDetail.setMinor((short) 1);
        exchange.getOut().setBody(new PingMeFault("PingMeFault raised by server", faultDetail));
        exchange.getOut().setFault(true);
    }
}
Also used : PingMeFault(org.apache.hello_world_soap_http.PingMeFault) Message(org.apache.camel.Message) FaultDetail(org.apache.hello_world_soap_http.types.FaultDetail)

Example 4 with FaultDetail

use of org.apache.hello_world_soap_http.types.FaultDetail in project camel by apache.

the class CxfHttpJmsClientServerTest method testClientInvocation.

@Test
public void testClientInvocation() throws MalformedURLException {
    String address = ROUTER_ADDRESS.replace("{{routerPort}}", System.getProperty("routerPort"));
    Client client = new Client(address + "?wsdl");
    Greeter proxy = client.getProxy();
    String resp;
    resp = proxy.sayHi();
    assertEquals("Get a wrong response", "Bonjour", resp);
    resp = proxy.greetMe("Willem");
    assertEquals("Get a wrong response", "Hello Willem", resp);
    proxy.greetMeOneWay(System.getProperty("user.name"));
    try {
        proxy.pingMe("hello");
        fail("exception expected but none thrown");
    } catch (PingMeFault ex) {
        FaultDetail detail = ex.getFaultInfo();
        assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
        assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
    }
}
Also used : PingMeFault(org.apache.hello_world_soap_http.PingMeFault) Greeter(org.apache.hello_world_soap_http.Greeter) FaultDetail(org.apache.hello_world_soap_http.types.FaultDetail) Test(org.junit.Test)

Example 5 with FaultDetail

use of org.apache.hello_world_soap_http.types.FaultDetail in project camel by apache.

the class GreeterImpl method pingMe.

public void pingMe(String messageIn) throws PingMeFault {
    FaultDetail faultDetail = new FaultDetail();
    faultDetail.setMajor((short) 2);
    faultDetail.setMinor((short) 1);
    LOG.info("Executing operation pingMe, throwing PingMeFault exception, message = " + messageIn);
    System.out.println("Executing operation pingMe, throwing PingMeFault exception\n");
    throw new PingMeFault("PingMeFault raised by server " + suffix, faultDetail);
}
Also used : PingMeFault(org.apache.hello_world_soap_http.PingMeFault) FaultDetail(org.apache.hello_world_soap_http.types.FaultDetail)

Aggregations

PingMeFault (org.apache.hello_world_soap_http.PingMeFault)7 FaultDetail (org.apache.hello_world_soap_http.types.FaultDetail)7 Greeter (org.apache.hello_world_soap_http.Greeter)3 Test (org.junit.Test)2 Message (org.apache.camel.Message)1