Search in sources :

Example 1 with PingMeFault

use of org.apache.hello_world_soap_http.PingMeFault 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 PingMeFault

use of org.apache.hello_world_soap_http.PingMeFault 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 PingMeFault

use of org.apache.hello_world_soap_http.PingMeFault 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 PingMeFault

use of org.apache.hello_world_soap_http.PingMeFault in project cxf by apache.

the class GreeterImpl method pingMe.

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

Example 5 with PingMeFault

use of org.apache.hello_world_soap_http.PingMeFault in project cxf by apache.

the class GreeterImpl method pingMe.

public void pingMe() throws PingMeFault {
    FaultDetail faultDetail = new FaultDetail();
    faultDetail.setMajor((short) 2);
    faultDetail.setMinor((short) 1);
    LOG.info("Executing operation pingMe, throwing PingMeFault exception");
    System.out.println("Executing operation pingMe, throwing PingMeFault exception\n");
    throw new PingMeFault("PingMeFault raised by server", 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)14 FaultDetail (org.apache.hello_world_soap_http.types.FaultDetail)12 Greeter (org.apache.hello_world_soap_http.Greeter)5 Test (org.junit.Test)3 URL (java.net.URL)2 SOAPService (org.apache.hello_world_soap_http.SOAPService)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CamelExecutionException (org.apache.camel.CamelExecutionException)1 Message (org.apache.camel.Message)1 ProducerTemplate (org.apache.camel.ProducerTemplate)1 Bus (org.apache.cxf.Bus)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1