Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Client-side logging info added

...

CXF includes two logging interceptors which output the incoming/outgoing messages to the Java log. To enable, you need to add these interceptors to your endpoint.

If Server-side, if you have a JAX-WS endpoint, you would want to do this:

Code Block
import javax.xml.ws.Endpoint;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;

EndpointImpl ep = (EndpointImpl) Endpoint.publish("http://localhost/service", service);

ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());

For client-side logging, the following code snippet can be used as an example:

Code Block

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;

public class WSClient {
    public static void main (String[] args) {
        MyService ws = new MyService();
        MyPortType port = ws.getPort();
        
        Client client = ClientProxy.getClient(port);
        client.getInInterceptors().add(new LoggingInInterceptor());
        client.getOutInterceptors().add(new LoggingOutInterceptor()); 
        
        // make WS calls...

You can also enable message logging through CXF configuration.

...