Examining your Java Application with a Debugging Proxy

Unless you’re one of those annoying people who never makes a mistake, the time will come when your java web application is choking on it’s web messages and you just don’t know why. When that time comes, one of things that you will really want to see are the raw messages going back and forth. Which may be a bit problematic if your tools have been hiding the raw messages from you.

When I find myself there, I like to set up a debugging proxy (an explicit proxy will also work). This is as easy as specifying a couple of system properties (http.proxyHost and http.proxyPort) on the command line. Here I show my Java web services message client using Fiddler as a debugging proxy.

1
1 $ java -classpath $AXISCLASSPATH -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888 Simple < data/echo.xml
<?xml version="1.0" standalone="yes" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:ns1="http://soapinterop.org/xsd">
  <soap:Body>
    <ns1:echoString>
      <ns1:echoStringRequest>Hello World</ns1:echoStringRequest>
    </ns1:echoString>
  </soap:Body>
</soap:Envelope>

Invoking http://stephan-desktop/axis/services/echo

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <ns2:echoStringResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns2="http://soapinterop.org/xsd">
    <return
        xsi:type="xsd:string"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Hello World</return>
  </ns2:echoStringResponse>
</soapenv:Body>

Producing the following view in Fiddler. Fiddler capture of a Java web services invocation

By selecting the “View in Notepad” button, we can see the complete response from the web service (formatted below for readability):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Header>
<ns1:echoMeStringResponse
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0"
xsi:type="soapenc:string"
xmlns:ns1="http://soapinterop.org/echoheader/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">header text</ns1:echoMeStringResponse>

</soapenv:Header>
<soapenv:Body>
<ns2:echoStringResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://soapinterop.org/xsd">

<return xsi:type="xsd:string">Hello World</return>
</ns2:echoStringResponse>
</soapenv:Body>
</soapenv:Envelope>