Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Children Display

Debugging Tools

Eclipse IDE

See this blog entry for information on debugging web services using Eclipse. Note this is primarily for tracing/debugging source code; you will probably still want to use one of the tools below to capture network traffic, view

Logging Messages

CXF uses Java SE Logging for both client- and server-side logging of SOAP requests and responses. Logging is activated by use of separate in/out interceptors that can be attached to the client and/or service as required. These interceptors can be specified either programmatically or via use of configuration files.

For programmatic configuration, the logging interceptors can be added to your service endpoint as follows:

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;

.......

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

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...

However, you will probably want to use configuration files for this. They offer two benefits over programmatic configuration:

  1. Logging requirements can be altered without needing to recompile the code
  2. No Apache CXF-specific APIs need to be added to your code, which helps it remain interoperable with other JAX-WS compliant web service stacks.

Enabling message logging through configuration files is shown here.

Configure logging levels.

In the /etc folder of the CXF distribution there is a sample Java SE logging.properties file you can use to configure logging. For example, if you want to change the console logging level from WARNING to FINE, you need to update two properties in this logging.properties file as below:

...


.level= FINE
java.util.logging.ConsoleHandler.level = FINE

Once this is done, you will need to set the -Djava.util.logging.config.file property to the location of the logging.properties file. As an example, the Ant target below has this property set:

...


<target name="runClient">
   <java classname="client.WSClient" fork="true">	    	
      <classpath>
         <pathelement location="${build.classes.dir}"/>
         <fileset dir="${env.CXF_HOME}/lib">
            <include name="*.jar"/>
         </fileset>
      </classpath>
      <jvmarg value="-Djava.util.logging.config.file=/usr/myclientapp/logging.properties"/>
   </java>
</target>

, etc.

NetBeans IDE

NetBeans include a debugger, profiler, and an HTTP monitor that can assist in troubleshooting SOA applications.

tcpmonplus

tcpmonplus allows you to easily view messages as they go back and forth on the wire.

WSMonitor

WSMonitor in another option to Tcpmon with slightly more functionality.

NetSniffer

NetSniffer makes it possible to track the network traffic between arbitrary devices within a LAN segment.

Wireshark

Wireshark, a network packet analyzer, is useful for following the routing of SOAP messages. It can also help when you are getting an HTML error message from the server that your CXF client cannot normally process, by allowing you to see the non-SOAP error message.

SOAP UI

SOAP UI can also be used for debugging. In addition to viewing messages, it allows you send messages and load test your services. It also has plugins for the Eclipse IDE, NetBeans IDE and IntelliJ IDEA.

Other Helpful Tools

WSDL Viewer

WSDL Viewer is a small tool to visualize web-services in a more intuitive way.

SOAP Fault for debugging

Stack trace in fault details

CXF supports the ability to put server stack trace information into the fault message fault details, if you enable the option of 'faultStackTraceEnabled'. It is useful for debugging if the soap fault message is not defined in the WSDL operation.

Code Block
<jaxws:endpoint id="server" address="http://localhost:9002/TestMessage" 
   wsdlURL="ship.wsdl"
   endpointName="s:TestSoapEndpoint"
   serviceName="s:TestService"
   xmlns:s="http://test" >
   <jaxws:properties>		
      <entry key="faultStackTraceEnabled" value="true" />
   </jaxws:properties>
</jaxws:endpoint>

Showing the cause exception message

CXF doesn't show the cause exception message in the fault message due to security consideration. However, this could potentially cause some trouble on the client side, as the client will not be able to see what the real cause of the exception is. You can let the CXF server return the fault message with the embedded cause exception message by enabling the option of 'exceptionMessageCauseEnabled' like this:

Code Block
<jaxws:endpoint id="server" address="http://localhost:9002/TestMessage" 
   wsdlURL="ship.wsdl"
   endpointName="s:TestSoapEndpoint"
   serviceName="s:TestService"
   xmlns:s="http://test" >
   <jaxws:properties>	
      <entry key="exceptionMessageCauseEnabled" value="true" />		
   </jaxws:properties>
</jaxws:endpoint>

 

 

Debugging Tools

Tcpmon

TCPMon allows you to easily view messages as they go back and forth on the wire.

WSMonitor

WSMonitor has slightly more functionality than Tcpmon. Information on how to reconfigure clients to work with WSMonitor is available in this blog entry.

SOAP UI

SOAP UI can also be used for debugging. In addition to viewing messages, it allows you send messages and load test your services. It also has plugins for Eclipse, IDEA and NetBeans.

Wireshark

Wireshark, a network packet analyzer, can be helpful in case you are getting cryptic WstxUnexpectedCharException errors from CXF's Woodstox StAX processor. This error can indicate a non-XML response from the server (e.g., an HTML error message) that Woodstox can't process. In these cases, Wireshark can help with troubleshooting by providing you the non-XML response data. See this blog entry for more information.