Search in sources :

Example 91 with Greeter

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

the class ThreadPoolTest method setUp.

@Before
public void setUp() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
    BindingProvider bp = (BindingProvider) greeter;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Before(org.junit.Before)

Example 92 with Greeter

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

the class Client method run.

@Override
public void run() {
    long start = System.currentTimeMillis();
    int x = 0;
    boolean exceeded = false;
    try (Greeter port = service.getSoapPort(new MetricsFeature())) {
        port.getRequestContext().put(MetricsProvider.CLIENT_ID, username);
        port.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
        port.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
        try {
            do {
                if (doStop) {
                    break;
                }
                port.greetMe(username + "-" + x);
                x++;
            } while (x < 10000);
        } catch (javax.xml.ws.WebServiceException wse) {
            if (wse.getCause().getMessage().contains("429")) {
                // exceeded are allowable number of requests
                exceeded = true;
            } else {
                wse.printStackTrace();
            }
        }
        long end = System.currentTimeMillis();
        double rate = x * 1000 / (end - start);
        System.out.println(username + " finished " + x + " invocations: " + rate + " req/sec " + (exceeded ? "(exceeded max)" : ""));
        try {
            // sleep for a few seconds before the client is closed so things can be seen in JMX
            Thread.sleep(10000);
        } catch (InterruptedException e) {
        // ignore
        }
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : MetricsFeature(org.apache.cxf.metrics.MetricsFeature) Greeter(org.apache.hello_world_soap_http.Greeter)

Example 93 with Greeter

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

the class ManagedConnectionImplTest method testAssociateConnection.

@Test
public void testAssociateConnection() throws Exception {
    CXFConnectionRequestInfo cri2 = new CXFConnectionRequestInfo(Greeter.class, new URL("file:/tmp/foo2"), new QName("service2"), new QName("fooPort2"));
    ManagedConnectionImpl mci2 = new ManagedConnectionImpl(factory, cri2, new Subject());
    mci2.addConnectionEventListener(mockListener);
    Object o = mci.getConnection(subj, cri);
    assertTrue("Returned connection does not implement Connection interface", o instanceof Connection);
    assertTrue("Returned connection does not implement Connection interface", o instanceof Greeter);
    assertTrue("Returned connection is not a java.lang.reflect.Proxy instance", o instanceof Proxy);
    InvocationHandler handler = Proxy.getInvocationHandler(o);
    assertTrue("Asserting handler class: " + handler.getClass(), handler instanceof CXFInvocationHandler);
    Object assocMci = ((CXFInvocationHandler) handler).getData().getManagedConnection();
    assertTrue("Asserting associated ManagedConnection.", mci == assocMci);
    assertTrue("Asserting associated ManagedConnection.", mci2 != assocMci);
    mci2.associateConnection(o);
    assocMci = ((CXFInvocationHandler) handler).getData().getManagedConnection();
    assertTrue("Asserting associated ManagedConnection.", mci2 == assocMci);
    assertTrue("Asserting associated ManagedConnection.", mci != assocMci);
}
Also used : Proxy(java.lang.reflect.Proxy) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_soap_http.Greeter) Connection(org.apache.cxf.connector.Connection) InvocationHandler(java.lang.reflect.InvocationHandler) ProxyInvocationHandler(org.apache.cxf.jca.cxf.handlers.ProxyInvocationHandler) URL(java.net.URL) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Example 94 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);
    }
    try {
        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 busFile = Client.class.getResource("/client.xml");
        Bus bus = bf.createBus(busFile.toString());
        BusFactory.setDefaultBus(bus);
        SOAPService service = new SOAPService(wsdlURL, SERVICE_NAME);
        Greeter port = service.getSoapPort();
        implicitPropagation(port);
        explicitPropagation(port);
        implicitPropagation(port);
    } catch (UndeclaredThrowableException ex) {
        ex.getUndeclaredThrowable().printStackTrace();
    } catch (Throwable ex) {
        ex.printStackTrace();
    } finally {
        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) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) File(java.io.File) URL(java.net.URL)

Example 95 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) {
    try {
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = Client.class.getResource("/client.xml");
        Bus bus = bf.createBus(busFile.toString());
        BusFactory.setDefaultBus(bus);
        SOAPService service = new SOAPService();
        Greeter port = service.getSoapPort();
        System.out.println("Invoking sayHi...");
        String resp = port.sayHi();
        System.out.println("Server responded with: " + resp + "\n");
        System.out.println("Invoking greetMe...");
        resp = port.greetMe(USER_NAME);
        System.out.println("Server responded with: " + resp + "\n");
        System.out.println("Invoking greetMeOneWay...");
        port.greetMeOneWay(USER_NAME);
        System.out.println("No response from server as method is OneWay\n");
        try {
            System.out.println("Invoking pingMe, expecting exception...");
            port.pingMe();
        } catch (PingMeFault ex) {
            System.out.println("Expected exception occurred: " + ex);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        System.exit(0);
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Bus(org.apache.cxf.Bus) PingMeFault(org.apache.hello_world_soap_http.PingMeFault) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world_soap_http.Greeter) 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