use of org.apache.cxf.interceptor.LoggingOutInterceptor in project cxf by apache.
the class LoggingFeature method initializeProvider.
@Override
protected void initializeProvider(InterceptorProvider provider, Bus bus) {
if (limit == DEFAULT_LIMIT && inLocation == null && outLocation == null && !prettyLogging) {
provider.getInInterceptors().add(IN);
provider.getInFaultInterceptors().add(IN);
provider.getOutInterceptors().add(OUT);
provider.getOutFaultInterceptors().add(OUT);
} else {
LoggingInInterceptor in = new LoggingInInterceptor(limit);
in.setOutputLocation(inLocation);
in.setPrettyLogging(prettyLogging);
in.setShowBinaryContent(showBinary);
LoggingOutInterceptor out = new LoggingOutInterceptor(limit);
out.setOutputLocation(outLocation);
out.setPrettyLogging(prettyLogging);
out.setShowBinaryContent(showBinary);
provider.getInInterceptors().add(in);
provider.getInFaultInterceptors().add(in);
provider.getOutInterceptors().add(out);
provider.getOutFaultInterceptors().add(out);
}
}
use of org.apache.cxf.interceptor.LoggingOutInterceptor in project Activiti by Activiti.
the class AbstractWebServiceTaskTest method initializeProcessEngine.
@Override
protected void initializeProcessEngine() {
super.initializeProcessEngine();
webServiceMock = new WebServiceMockImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(WebServiceMock.class);
svrFactory.setAddress(WEBSERVICE_MOCK_ADDRESS);
svrFactory.setServiceBean(webServiceMock);
svrFactory.getInInterceptors().add(new LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
server = svrFactory.create();
server.start();
}
use of org.apache.cxf.interceptor.LoggingOutInterceptor in project midpoint by Evolveum.
the class AbstractWebserviceTest method createModelPort.
/**
* Creates webservice client connecting to midpoint
* */
protected static ModelPortType createModelPort(String username, String password, String passwordType) {
String endpoint = ENDPOINT;
if (System.getProperty("midpoint.endpoint") != null) {
endpoint = System.getProperty("midpoint.endpoint");
}
LOGGER.info("Creating model client endpoint: {} , username={}, password={}", new Object[] { endpoint, username, password });
ModelService modelService = new ModelService();
ModelPortType modelPort = modelService.getModelPort();
BindingProvider bp = (BindingProvider) modelPort;
Map<String, Object> requestContext = bp.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
Map<String, Object> outProps = new HashMap<String, Object>();
if (username != null) {
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
outProps.put(WSHandlerConstants.USER, username);
outProps.put(WSHandlerConstants.PASSWORD_TYPE, passwordType);
ClientPasswordHandler.setPassword(password);
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
}
cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
return modelPort;
}
use of org.apache.cxf.interceptor.LoggingOutInterceptor in project camel by apache.
the class LoggingInterceptorInMessageModeTest method testInvokingServiceFromCXFClient.
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
LoggingOutInterceptor logInterceptor = null;
for (Interceptor<?> interceptor : context.getEndpoint("cxf:bean:serviceEndpoint", CxfSpringEndpoint.class).getOutInterceptors()) {
if (interceptor instanceof LoggingOutInterceptor) {
logInterceptor = LoggingOutInterceptor.class.cast(interceptor);
break;
}
}
assertNotNull(logInterceptor);
// StringPrintWriter writer = new StringPrintWriter();
// Unfortunately, LoggingOutInterceptor does not have a setter for writer so
// we can't capture the output to verify.
// logInterceptor.setPrintWriter(writer);
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(ROUTER_ADDRESS);
clientBean.setServiceClass(HelloService.class);
HelloService client = (HelloService) proxyFactory.create();
String result = client.echo("hello world");
assertEquals("we should get the right answer from router", result, "echo hello world");
//assertTrue(writer.getString().indexOf("hello world") > 0);
}
use of org.apache.cxf.interceptor.LoggingOutInterceptor in project camel by apache.
the class CXFWsdlOnlyPayloadModeNoSpringTest method testApplicationFault.
@Test
public void testApplicationFault() {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
Person client = ss.getSoap();
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port1 + "/" + getClass().getSimpleName() + "/PersonService");
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
Holder<String> personId = new Holder<String>();
personId.value = "";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
Throwable t = null;
try {
client.getPerson(personId, ssn, name);
fail("expect UnknownPersonFault");
} catch (UnknownPersonFault e) {
t = e;
}
assertNotNull(t);
assertTrue(t instanceof UnknownPersonFault);
}
Aggregations