use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class WSSecurityClientTest method testUsernameTokenStreaming.
@Test
public void testUsernameTokenStreaming() throws Exception {
final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, GREETER_SERVICE_QNAME);
final Greeter greeter = svc.getPort(USERNAME_TOKEN_PORT_QNAME, Greeter.class);
updateAddressPort(greeter, test.getPort());
Client client = ClientProxy.getClient(greeter);
Map<String, Object> props = new HashMap<>();
props.put("action", "UsernameToken");
props.put("user", "alice");
props.put("passwordType", "PasswordText");
WSS4JStaxOutInterceptor wss4jOut = new WSS4JStaxOutInterceptor(props);
client.getOutInterceptors().add(wss4jOut);
((BindingProvider) greeter).getRequestContext().put("password", "password");
try {
greeter.greetMe("CXF");
fail("should fail because of password text instead of digest");
} catch (Exception ex) {
// expected
}
client.getOutInterceptors().remove(wss4jOut);
props.put("passwordType", "PasswordDigest");
wss4jOut = new WSS4JStaxOutInterceptor(props);
client.getOutInterceptors().add(wss4jOut);
String s = greeter.greetMe("CXF");
assertEquals("Hello CXF", s);
client.getOutInterceptors().remove(wss4jOut);
try {
((BindingProvider) greeter).getRequestContext().put("password", "foo");
wss4jOut = new WSS4JStaxOutInterceptor(props);
client.getOutInterceptors().add(wss4jOut);
greeter.greetMe("CXF");
fail("should fail");
} catch (Exception ex) {
// expected
}
client.getOutInterceptors().remove(wss4jOut);
try {
props.put("passwordType", "PasswordText");
wss4jOut = new WSS4JStaxOutInterceptor(props);
client.getOutInterceptors().add(wss4jOut);
((BindingProvider) greeter).getRequestContext().put("password", "password");
greeter.greetMe("CXF");
fail("should fail");
} catch (Exception ex) {
// expected
}
client.getOutInterceptors().remove(wss4jOut);
((java.io.Closeable) greeter).close();
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class WSSecurityClientTest method testUsernameToken.
@Test
public void testUsernameToken() throws Exception {
final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, GREETER_SERVICE_QNAME);
final Greeter greeter = svc.getPort(USERNAME_TOKEN_PORT_QNAME, Greeter.class);
updateAddressPort(greeter, test.getPort());
Client client = ClientProxy.getClient(greeter);
Map<String, Object> props = new HashMap<>();
props.put("action", "UsernameToken");
props.put("user", "alice");
props.put("passwordType", "PasswordText");
WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor(props);
client.getOutInterceptors().add(wss4jOut);
((BindingProvider) greeter).getRequestContext().put("password", "password");
try {
greeter.greetMe("CXF");
fail("should fail because of password text instead of digest");
} catch (Exception ex) {
// expected
}
props.put("passwordType", "PasswordDigest");
String s = greeter.greetMe("CXF");
assertEquals("Hello CXF", s);
try {
((BindingProvider) greeter).getRequestContext().put("password", "foo");
greeter.greetMe("CXF");
fail("should fail");
} catch (Exception ex) {
// expected
}
try {
props.put("passwordType", "PasswordText");
((BindingProvider) greeter).getRequestContext().put("password", "password");
greeter.greetMe("CXF");
fail("should fail");
} catch (Exception ex) {
// expected
}
((java.io.Closeable) greeter).close();
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class WSSecurityClientTest method testTimestampSignEncrypt.
@Test
public void testTimestampSignEncrypt() throws Exception {
Bus b = new SpringBusFactory().createBus("org/apache/cxf/systest/ws/security/client.xml");
BusFactory.setDefaultBus(b);
final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, GREETER_SERVICE_QNAME);
final Greeter greeter = svc.getPort(TIMESTAMP_SIGN_ENCRYPT_PORT_QNAME, Greeter.class);
updateAddressPort(greeter, test.getPort());
// Add a No-Op JAX-WS SoapHandler to the dispatch chain to
// verify that the SoapHandlerInterceptor can peacefully co-exist
// with the explicitly configured SAAJOutInterceptor
//
@SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<>();
Binding binding = ((BindingProvider) greeter).getBinding();
TestOutHandler handler = new TestOutHandler();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
greeter.sayHi();
assertTrue("expected Handler.handleMessage() to be called", handler.handleMessageCalledOutbound);
assertFalse("expected Handler.handleFault() not to be called", handler.handleFaultCalledOutbound);
((java.io.Closeable) greeter).close();
b.shutdown(true);
BusFactory.setDefaultBus(getStaticBus());
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class AsyncHTTPConduitTest method testInovationWithHCAddress.
@Test
public void testInovationWithHCAddress() throws Exception {
String address = "hc://http://localhost:" + PORT + "/SoapContext/SoapPort";
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Greeter.class);
factory.setAddress(address);
Greeter greeter = factory.create(Greeter.class);
String response = greeter.greetMe("test");
assertEquals("Get a wrong response", "Hello test", response);
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class AsyncHTTPConduitTest method testInvocationWithTransportId.
@Test
public void testInvocationWithTransportId() throws Exception {
String address = "http://localhost:" + PORT + "/SoapContext/SoapPort";
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Greeter.class);
factory.setAddress(address);
factory.setTransportId("http://cxf.apache.org/transports/http/http-client");
Greeter greeter = factory.create(Greeter.class);
String response = greeter.greetMe("test");
assertEquals("Get a wrong response", "Hello test", response);
}
Aggregations