Search in sources :

Example 26 with Greeter

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

the class JaxWsClientTest method testRequestContextPutAndRemoveEcho.

@Test
public void testRequestContextPutAndRemoveEcho() throws Exception {
    URL url = getClass().getResource("/wsdl/hello_world.wsdl");
    javax.xml.ws.Service s = javax.xml.ws.Service.create(url, serviceName);
    final Greeter handler = s.getPort(portName, Greeter.class);
    Map<String, Object> requestContext = ((BindingProvider) handler).getRequestContext();
    requestContext.put(JaxWsClientProxy.THREAD_LOCAL_REQUEST_CONTEXT, Boolean.TRUE);
    // future calls to getRequestContext() will use a thread local request context.
    // That allows the request context to be threadsafe.
    requestContext = ((BindingProvider) handler).getRequestContext();
    final String key = "Hi";
    requestContext.put(key, "ho");
    final Object[] result = new Object[2];
    Thread t = new Thread() {

        public void run() {
            // requestContext in main thread shouldn't affect the requestContext in this thread
            Map<String, Object> requestContext = ((BindingProvider) handler).getRequestContext();
            result[0] = requestContext.get(key);
            requestContext.remove(key);
            result[1] = requestContext.get(key);
        }
    };
    t.start();
    t.join();
    assertNull("thread shouldn't see the put", result[0]);
    assertNull("thread did not remove the put", result[1]);
    assertEquals("main thread does not see removal", "ho", requestContext.get(key));
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 27 with Greeter

use of org.apache.hello_world_soap_http.Greeter 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 28 with Greeter

use of org.apache.hello_world_soap_http.Greeter 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 29 with Greeter

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

the class Client method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("please specify wsdl");
        System.exit(1);
    }
    URL wsdlURL;
    File wsdlFile = new File(args[0]);
    if (wsdlFile.exists()) {
        wsdlURL = wsdlFile.toURI().toURL();
    } else {
        wsdlURL = new URL(args[0]);
    }
    System.out.println("WSDL : " + wsdlURL);
    SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
    Greeter port = ss.getPort(PORT_NAME, Greeter.class);
    System.out.println("Invoking greetMe...");
    try {
        String resp = port.greetMe(System.getProperty("user.name"));
        System.out.println("Server responded with: " + resp);
        System.out.println();
    } catch (Exception e) {
        System.out.println("Invocation failed with the following: " + e.getCause());
        System.out.println();
    }
    System.exit(0);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) File(java.io.File) URL(java.net.URL)

Example 30 with Greeter

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

the class Client method main.

public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        System.out.println("please specify wsdl and configuration file");
        System.exit(1);
    }
    URL wsdlURL;
    File wsdlFile = new File(args[0]);
    if (wsdlFile.exists()) {
        wsdlURL = wsdlFile.toURI().toURL();
    } else {
        wsdlURL = new URL(args[0]);
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busURL;
    File busFile = new File(args[1]);
    if (busFile.exists()) {
        busURL = busFile.toURI().toURL();
    } else {
        busURL = new URL(args[1]);
    }
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    System.out.println(wsdlURL);
    SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
    Greeter port = ss.getPort(PORT_NAME, Greeter.class);
    System.out.println("Invoking greetMe...");
    try {
        String resp = port.greetMe(System.getProperty("user.name"));
        System.out.println("Server responded with: " + resp);
        System.out.println();
    } catch (Exception e) {
        System.out.println("Invocation failed with the following: " + e.getCause());
        System.out.println();
    }
    System.exit(0);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world_soap_http.Greeter) File(java.io.File) URL(java.net.URL)

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