use of org.apache.cxf.ext.logging.LoggingInInterceptor in project cxf by apache.
the class StaxToDOMRoundTripTest method testSignaturePKI.
@Test
public void testSignaturePKI() throws Exception {
// Create + configure service
Service service = createService();
Map<String, Object> inProperties = new HashMap<>();
inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new KeystorePasswordCallback());
inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "cxfca.properties");
WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
service.getInInterceptors().add(inInterceptor);
// Create + configure client
Echo echo = createClientProxy();
Client client = ClientProxy.getClient(echo);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
WSSSecurityProperties properties = new WSSSecurityProperties();
List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureUser("alice");
Properties cryptoProperties = CryptoFactory.getProperties("alice.properties", this.getClass().getClassLoader());
properties.setSignatureCryptoProperties(cryptoProperties);
properties.setCallbackHandler(new KeystorePasswordCallback());
properties.setUseSingleCert(true);
properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE);
WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
client.getOutInterceptors().add(ohandler);
assertEquals("test", echo.echo("test"));
}
use of org.apache.cxf.ext.logging.LoggingInInterceptor in project cxf by apache.
the class JaxWsDynamicClientTest method testArgfiles.
@Test
public void testArgfiles() throws Exception {
System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true");
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl"));
String[] values = new String[] { "foobar", "something" };
List<String> list = Arrays.asList(values);
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getInInterceptors().add(new LoggingInInterceptor());
client.invoke("init", list);
}
use of org.apache.cxf.ext.logging.LoggingInInterceptor in project cxf by apache.
the class JaxWsDynamicClientTest method testArrayList.
@Test
public void testArrayList() throws Exception {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl"));
String[] values = new String[] { "foobar", "something" };
List<String> list = Arrays.asList(values);
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getInInterceptors().add(new LoggingInInterceptor());
client.invoke("init", list);
}
use of org.apache.cxf.ext.logging.LoggingInInterceptor in project cxf by apache.
the class CXF6655Test method testConnectionWithProxy.
@Test
public void testConnectionWithProxy() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/systest/jaxws/", "HelloService");
HelloService service = new HelloService(null, serviceName);
assertNotNull(service);
Hello hello = service.getHelloPort();
Client client = ClientProxy.getClient(hello);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(0);
httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
httpClientPolicy.setProxyServer("localhost");
httpClientPolicy.setProxyServerPort(PROXY_PORT);
http.setClient(httpClientPolicy);
((BindingProvider) hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/hello");
assertEquals("getSayHi", hello.sayHi("SayHi"));
}
use of org.apache.cxf.ext.logging.LoggingInInterceptor in project cxf by apache.
the class ClientServerRPCLitTest method testBasicConnection.
@Test
public void testBasicConnection() throws Exception {
SOAPServiceRPCLit service = new SOAPServiceRPCLit();
assertNotNull(service);
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
try {
GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
updateAddressPort(greeter, PORT);
for (int idx = 0; idx < 1; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
String exResponse = response1 + idx;
assertEquals(exResponse, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
try {
greeter.greetMe("return null");
fail("should catch WebServiceException");
} catch (WebServiceException e) {
// do nothing
} catch (Exception e) {
fail("should catch WebServiceException");
throw e;
}
try {
greeter.greetMe(null);
fail("should catch WebServiceException");
} catch (WebServiceException e) {
// do nothing
} catch (Exception e) {
fail("should catch WebServiceException");
throw e;
}
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
Aggregations