Trace SOAP request/response using JAX-WS

Trace SOAP request/response using JAX-WS explains about how to trace the raw XML request and response usng java's in-bult JAX-WS implementation

It is a life saver, when we dont know the exact request which we are passing to the server.

For deploying the service, you can follow this tutorial CXF Web Service Tutorial. After the deployment you can access the below url


Here I am generating Java Code From A WSDL Document using wsimport tool, So that client can Invoke/Consume the Service


1) If you need Eclipse IDE example, You can follow Trace SOAP message Using Eclipse IDE

2) If you need tcpmon example, You can follow TCPMon Tutorial

Required Libraries

You need to download

  1. JDK 7 (wsimport tool is available from jdk5 onwards)

You can view the generated code on below screenshot

wsimport Example

Run Client

Below code you can see the bold characters, which is used for tracing the SOAP request/response

package com.student;

import com.student.ChangeStudentDetails;
import com.student.ChangeStudentDetailsImplService;
import com.student.Student;

// Trace XML request/response using JAX-WS

public class Main {

public static void main(String[] args) {

//For tracing the SOAP message

System.setProperty("", "true");
("", "true");
("", "true");
("", "true");

        ChangeStudentDetailsImplService service =
new ChangeStudentDetailsImplService();
        ChangeStudentDetails changeStudentDetailsImplPort = service.getChangeStudentDetailsImplPort
        Student student =
new Student();
        Student changeName = changeStudentDetailsImplPort.changeName
("Server said: " + changeName.getName());

---[HTTP request - http://localhost:8080/CXFTutorial/ChangeStudent]---
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e
<?xml version="1.0" ?><S:Envelope xmlns:S=""><S:Body><ns2:changeName xmlns:ns2=""><arg0><name>Rockey</name></arg0></ns2:changeName></S:Body></S:Envelope>--------------------

---[HTTP response - http://localhost:8080/CXFTutorial/ChangeStudent - 200]---
null: HTTP/1.1 200 OK
Content-Length: 232
Content-Type: text/xml;charset=UTF-8
Date: Fri, 22 Jan 2016 12:42:01 GMT
Server: Apache-Coyote/1.1
<soap:Envelope xmlns:soap=""><soap:Body><ns2:changeNameResponse xmlns:ns2=""><return><name>Hello Rockey</name></return></ns2:changeNameResponse></soap:Body></soap:Envelope>--------------------

Server said: Hello Rockey

Your email address will not be published. Required fields are marked *