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