Overview
Most of the time, developers are developing the web services but they do not have the idea what's happening behind the screen. Using the web services client, you have the better idea of the request and response, the mandatory and optional fields etc. When you are consuming the web services through the code, you are looking at the code level and not the final Soap envelop structure. In this post, I will show you how to print the Soap request and response using the Apache CXF framework for easy debuggingApache CXF
is an open source framework provided by Apache. It helps you to develop and consume the web services. It has the support for a variety of protocols like SOAP, RESTful and CORBA etc.
Logging the Soap Request and Response
Using Apache CXF, you can print/log the request and response using the interceptors. Interceptors are the basic processing units of the CXF framework. When a client requests a server using the SOAP, a chain of interceptors is formed for receiving of a message, validation, transformation etc.
We can print the request and response using the following two ways
Configuration
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" parent="abstractLoggingInterceptor" />
Code
Client clientService = ClientProxy.getClient(service); clientService.getOutInterceptors().add(new LoggingOutInterceptor());
Please leave your comments and valuable feedback.
Comments
Post a Comment