Search in sources :

Example 66 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project camel by apache.

the class CxfSoapMessageProviderTest method testSOAPMessageModeDocLit.

@Test
public void testSOAPMessageModeDocLit() throws Exception {
    JaxwsTestHandler fromHandler = getMandatoryBean(JaxwsTestHandler.class, "fromEndpointJaxwsHandler");
    fromHandler.reset();
    QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
    QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);
    String response1 = new String("TestSOAPOutputPMessage");
    String response2 = new String("Bonjour");
    try {
        Greeter greeter = service.getPort(portName, Greeter.class);
        ((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port + "/CxfSoapMessageProviderTest/SoapContext/SoapProviderPort");
        for (int idx = 0; idx < 2; idx++) {
            String greeting = greeter.greetMe("Milestone-" + idx);
            assertNotNull("no response received from service", greeting);
            assertEquals(response1, greeting);
            String reply = greeter.sayHi();
            assertNotNull("no response received from service", reply);
            assertEquals(response2, reply);
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
    assertEquals("Can't get the right message count", fromHandler.getMessageCount(), 8);
    assertEquals("Can't get the right fault count", fromHandler.getFaultCount(), 0);
//From CXF 2.2.7 the soap handler's getHeader() method will not be called if the SOAP message don't have headers
//assertEquals("Can't get the right headers count", fromHandler.getGetHeadersCount(), 4);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) JaxwsTestHandler(org.apache.camel.wsdl_first.JaxwsTestHandler) URL(java.net.URL) Test(org.junit.Test)

Example 67 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project camel by apache.

the class CxfOneWayRouteTest method testInvokingOneWayServiceFromCXFClient.

@Test
public void testInvokingOneWayServiceFromCXFClient() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.expectedFileExists("target/camel-file/cxf-oneway-route");
    Greeter client = getCXFClient();
    client.greetMeOneWay("lemac");
    // may need to wait until the oneway call completes 
    long waitUntil = System.currentTimeMillis() + 10000;
    while (!bindingDone && System.currentTimeMillis() < waitUntil) {
        Thread.sleep(1000);
    }
    assertMockEndpointsSatisfied();
    assertNull("exception occured: " + bindingException, bindingException);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Greeter(org.apache.hello_world_soap_http.Greeter) Test(org.junit.Test)

Example 68 with Greeter

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

the class ClientServerTest method testTimeoutConfigutation.

@Test
public void testTimeoutConfigutation() throws Exception {
    SOAPService service = new SOAPService();
    assertNotNull(service);
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);
    ((javax.xml.ws.BindingProvider) greeter).getRequestContext().put("javax.xml.ws.client.receiveTimeout", "1");
    try {
        greeter.greetMe("test");
    // remove fail() check to let this test pass in the powerful machine
    } catch (Throwable ex) {
        Object cause = null;
        if (ex.getCause() != null) {
            cause = ex.getCause();
        }
        assertTrue("Timeout cause is expected", cause instanceof java.net.SocketTimeoutException);
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) SOAPServiceMultiPortTypeTest(org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) Test(org.junit.Test)

Example 69 with Greeter

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

the class ClientServerTest method testAsyncDiscardProxy.

@Test
public void testAsyncDiscardProxy() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);
    Greeter greeter = service.getPort(portName, Greeter.class);
    assertNotNull(service);
    updateAddressPort(greeter, PORT);
    Response<GreetMeLaterResponse> r1 = greeter.greetMeLaterAsync(3000);
    greeter = null;
    service = null;
    System.gc();
    System.gc();
    System.gc();
    assertEquals("Hello, finally!", r1.get().getResponseType());
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) GreetMeLaterResponse(org.apache.hello_world_soap_http.types.GreetMeLaterResponse) URL(java.net.URL) SOAPServiceMultiPortTypeTest(org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) Test(org.junit.Test)

Example 70 with Greeter

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

the class ClientServerTest method testBasicConnection.

@Test
public void testBasicConnection() throws Exception {
    SOAPService service = new SOAPService();
    assertNotNull(service);
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);
    try {
        greeter.greetMe("test");
        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals("Bonjour", reply);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
    BindingProvider bp = (BindingProvider) greeter;
    Map<String, Object> responseContext = bp.getResponseContext();
    Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
    assertEquals(200, responseCode.intValue());
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) BindingProvider(javax.xml.ws.BindingProvider) SOAPServiceMultiPortTypeTest(org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) Test(org.junit.Test)

Aggregations

Greeter (org.apache.hello_world_soap_http.Greeter)104 Test (org.junit.Test)78 SOAPService (org.apache.hello_world_soap_http.SOAPService)55 URL (java.net.URL)47 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)24 BindingProvider (javax.xml.ws.BindingProvider)23 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)21 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)21 Service (javax.xml.ws.Service)19 Client (org.apache.cxf.endpoint.Client)17 Endpoint (javax.xml.ws.Endpoint)13 QName (javax.xml.namespace.QName)10 Bus (org.apache.cxf.Bus)10 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)10 ExecutorService (java.util.concurrent.ExecutorService)9 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)7 File (java.io.File)6 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)6 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)6 InvocationHandler (java.lang.reflect.InvocationHandler)5