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]);
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = null;
if ("secure".equals(args[1])) {
busFile = Client.class.getResource("/SecureClient.xml");
} else if ("insecure".equals(args[1])) {
busFile = Client.class.getResource("/InsecureClient.xml");
} else {
System.out.println("arg1 needs to be either secure or insecure");
System.exit(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);
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientNonSpring 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(wsdlURL);
SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
Greeter port = ss.getPort(PORT_NAME, Greeter.class);
if ("secure".equals(args[1])) {
setupTLS(port);
} else if ("insecure".equals(args[1])) {
// do nothing
} else {
System.out.println("arg1 needs to be either secure or insecure");
System.exit(1);
}
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 EndpointReferenceTest method testProviderGetPort.
@Test
public void testProviderGetPort() throws Exception {
BusFactory.setDefaultBus(getBus());
GreeterImpl greeter1 = new GreeterImpl();
try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
endpoint.publish("http://localhost:8080/test");
ProviderImpl provider = new ProviderImpl();
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = EndpointReference.readFrom(erXML);
WebServiceFeature[] wfs = new WebServiceFeature[] {};
Greeter greeter = provider.getPort(endpointReference, Greeter.class, wfs);
String response = greeter.greetMe("John");
assertEquals("Hello John", response);
}
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class EndpointReferenceTest method testBindingProviderSOAPBindingStaicService.
@Test
public void testBindingProviderSOAPBindingStaicService() throws Exception {
org.apache.hello_world_soap_http.SOAPService s = new org.apache.hello_world_soap_http.SOAPService();
Greeter greeter = s.getPort(Greeter.class);
BindingProvider bindingProvider = (BindingProvider) greeter;
EndpointReference er = bindingProvider.getEndpointReference();
assertNotNull(er);
// If the BindingProvider instance has a binding that is either SOAP 1.1/HTTP or SOAP
// 1.2/HTTP, then a W3CEndpointReference MUST be returned.
assertTrue(er instanceof W3CEndpointReference);
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class JaxWsClientTest method testThreadLocalRequestContextIsIsolated.
@Test
public void testThreadLocalRequestContextIsIsolated() throws InterruptedException {
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);
final AtomicBoolean isPropertyAPresent = new AtomicBoolean(false);
// Makes request context thread local
ClientProxy.getClient(handler).setThreadLocalRequestContext(true);
// PropertyA should be added to the request context of current thread only
ClientProxy.getClient(handler).getRequestContext().put("PropertyA", "PropertyAVal");
Runnable checkRequestContext = new Runnable() {
@Override
public void run() {
if (ClientProxy.getClient(handler).getRequestContext().containsKey("PropertyA")) {
isPropertyAPresent.set(true);
}
}
};
Thread thread = new Thread(checkRequestContext);
thread.start();
thread.join(60000);
assertFalse("If we have per thread isolation propertyA should be not present in the context of another thread.", isPropertyAPresent.get());
}
Aggregations