Search in sources :

Example 31 with SOAPService

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

the class ServiceImplTest method testNonSpecificGetPort.

@Test
public void testNonSpecificGetPort() throws Exception {
    SOAPService service = new SOAPService();
    Greeter proxy = service.getPort(Greeter.class);
    Client client = ClientProxy.getClient(proxy);
    boolean boolA = client.getEndpoint().getEndpointInfo().getName().equals(SOAP_PORT);
    boolean boolB = client.getEndpoint().getEndpointInfo().getName().equals(SOAP_PORT1);
    assertTrue(boolA || boolB);
    assertNotNull("expected ConduitSelector", client.getConduitSelector());
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 32 with SOAPService

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

the class ServiceImplTest method testServiceImpl.

@Test
public void testServiceImpl() throws Exception {
    SOAPService service = new SOAPService();
    Greeter proxy = service.getSoapPort();
    Client client = ClientProxy.getClient(proxy);
    assertEquals("bar", client.getEndpoint().get("foo"));
    assertNotNull("expected ConduitSelector", client.getConduitSelector());
    assertTrue("unexpected ConduitSelector", client.getConduitSelector() instanceof NullConduitSelector);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) Client(org.apache.cxf.endpoint.Client) NullConduitSelector(org.apache.cxf.endpoint.NullConduitSelector) Test(org.junit.Test)

Example 33 with SOAPService

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

the class ConfiguredEndpointTest method doTestConfiguredClientEndpoint.

private void doTestConfiguredClientEndpoint() {
    javax.xml.ws.Service service = new SOAPService();
    Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
    JaxWsClientProxy eih = (JaxWsClientProxy) Proxy.getInvocationHandler(greeter);
    Client client = eih.getClient();
    JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl) client.getEndpoint();
    org.apache.cxf.service.ServiceImpl svc = (org.apache.cxf.service.ServiceImpl) endpoint.getService();
    assertEquals("Unexpected bean name.", SERVICE_NAME.toString(), svc.getBeanName());
    List<Interceptor<? extends Message>> interceptors = svc.getInInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-in", findTestInterceptor(interceptors).getId());
    interceptors = svc.getOutInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-out", findTestInterceptor(interceptors).getId());
    interceptors = svc.getInFaultInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-in-fault", findTestInterceptor(interceptors).getId());
    interceptors = svc.getOutFaultInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-out-fault", findTestInterceptor(interceptors).getId());
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Message(org.apache.cxf.message.Message) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) Greeter(org.apache.hello_world_soap_http.Greeter) Client(org.apache.cxf.endpoint.Client) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor)

Example 34 with SOAPService

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

the class ConfiguredEndpointTest method doTestDefaultClientEndpoint.

private void doTestDefaultClientEndpoint() {
    javax.xml.ws.Service service = new SOAPService();
    Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
    JaxWsClientProxy eih = (JaxWsClientProxy) Proxy.getInvocationHandler(greeter);
    Client client = eih.getClient();
    JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl) client.getEndpoint();
    assertEquals("Unexpected bean name", PORT_NAME.toString() + ".endpoint", endpoint.getBeanName());
    assertFalse("Unexpected value for property validating", Boolean.TRUE.equals(endpoint.get(Message.SCHEMA_VALIDATION_ENABLED)));
    // System.out.println("endpoint interceptors");
    List<Interceptor<? extends Message>> interceptors = endpoint.getInInterceptors();
    printInterceptors("in", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = endpoint.getOutInterceptors();
    printInterceptors("out", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = endpoint.getInFaultInterceptors();
    printInterceptors("inFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = endpoint.getOutFaultInterceptors();
    printInterceptors("outFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    // System.out.println("service interceptors");
    org.apache.cxf.service.ServiceImpl svc = (org.apache.cxf.service.ServiceImpl) endpoint.getService();
    assertEquals("Unexpected bean name", SERVICE_NAME.toString(), svc.getBeanName());
    interceptors = svc.getInInterceptors();
    printInterceptors("in", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = svc.getOutInterceptors();
    printInterceptors("out", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = svc.getInFaultInterceptors();
    printInterceptors("inFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = svc.getOutFaultInterceptors();
    printInterceptors("outFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Message(org.apache.cxf.message.Message) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) Greeter(org.apache.hello_world_soap_http.Greeter) Client(org.apache.cxf.endpoint.Client) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor)

Example 35 with SOAPService

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

the class ClientServerTest method testAsyncSynchronousPolling.

@Test
public void testAsyncSynchronousPolling() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);
    final String expectedString = new String("Hello, finally!");
    class Poller extends Thread {

        Response<GreetMeLaterResponse> response;

        int tid;

        Poller(Response<GreetMeLaterResponse> r, int t) {
            response = r;
            tid = t;
        }

        public void run() {
            if (tid % 2 > 0) {
                while (!response.isDone()) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                    // ignore
                    }
                }
            }
            GreetMeLaterResponse reply = null;
            try {
                reply = response.get();
            } catch (Exception ex) {
                fail("Poller " + tid + " failed with " + ex);
            }
            assertNotNull("Poller " + tid + ": no response received from service", reply);
            String s = reply.getResponseType();
            assertEquals(expectedString, s);
        }
    }
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);
    long before = System.currentTimeMillis();
    long delay = 3000;
    Response<GreetMeLaterResponse> response = greeter.greetMeLaterAsync(delay);
    long after = System.currentTimeMillis();
    assertTrue("Duration of calls exceeded " + delay + " ms", after - before < delay);
    // first time round, responses should not be available yet
    assertFalse("Response already available.", response.isDone());
    Poller[] pollers = new Poller[4];
    for (int i = 0; i < pollers.length; i++) {
        pollers[i] = new Poller(response, i);
    }
    for (Poller p : pollers) {
        p.start();
    }
    for (Poller p : pollers) {
        p.join();
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) GreetMeLaterResponse(org.apache.hello_world_soap_http.types.GreetMeLaterResponse) URL(java.net.URL) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) ExecutionException(java.util.concurrent.ExecutionException) WebServiceException(javax.xml.ws.WebServiceException) Endpoint(javax.xml.ws.Endpoint) BareDocumentResponse(org.apache.hello_world_soap_http.types.BareDocumentResponse) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) GreetMeLaterResponse(org.apache.hello_world_soap_http.types.GreetMeLaterResponse) Response(javax.xml.ws.Response) 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)

Aggregations

SOAPService (org.apache.hello_world_soap_http.SOAPService)84 URL (java.net.URL)67 Test (org.junit.Test)56 Greeter (org.apache.hello_world_soap_http.Greeter)49 InputStream (java.io.InputStream)20 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)18 SOAPMessage (javax.xml.soap.SOAPMessage)14 Bus (org.apache.cxf.Bus)14 BindingProvider (javax.xml.ws.BindingProvider)13 Endpoint (javax.xml.ws.Endpoint)13 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)13 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)13 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)12 TimeoutException (java.util.concurrent.TimeoutException)8 WebServiceException (javax.xml.ws.WebServiceException)8 File (java.io.File)7 ExecutionException (java.util.concurrent.ExecutionException)7 QName (javax.xml.namespace.QName)7 BeforeClass (org.junit.BeforeClass)7 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)6