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);
}
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();
}
}
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);
}
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);
}
}
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);
}
}
Aggregations