Search in sources :

Example 11 with LoggingOutInterceptor

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);
    }
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor)

Example 12 with LoggingOutInterceptor

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();
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 13 with LoggingOutInterceptor

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;
}
Also used : ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) BindingProvider(javax.xml.ws.BindingProvider) ModelService(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)

Example 14 with LoggingOutInterceptor

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);
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Test(org.junit.Test)

Example 15 with LoggingOutInterceptor

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);
}
Also used : UnknownPersonFault(org.apache.camel.wsdl_first.UnknownPersonFault) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) Test(org.junit.Test)

Aggregations

LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)19 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)18 Client (org.apache.cxf.endpoint.Client)6 Test (org.junit.Test)6 URL (java.net.URL)4 BindingProvider (javax.xml.ws.BindingProvider)4 Holder (javax.xml.ws.Holder)4 Person (org.apache.camel.wsdl_first.Person)4 PersonService (org.apache.camel.wsdl_first.PersonService)4 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)4 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)3 ModelService (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService)3 HashMap (java.util.HashMap)3 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 UnknownPersonFault (org.apache.camel.wsdl_first.UnknownPersonFault)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 ClientPasswordHandler (com.evolveum.midpoint.cli.ninja.util.ClientPasswordHandler)1 SHSIMPINC (com.ibm.maximo.wsdl.shsimpinc.SHSIMPINC)1 IOException (java.io.IOException)1