Wednesday, January 09, 2008

TCP Monitor tool with WSO2 WSF/C

The TCPMonitor tool can be used to listen to TCP(Transmission Control Protocol) endpoints in your system. When you download and build WSO2 WSF/C, the tool is available at WSFC_HOME/bin/tools for your convenience. Go to the directory and start the tool as follows.

%tcpmon.exe
Note that I've used .exe for the Win32 systems. UNIX guys please use
%./tcpmon

OK. Now by default, the tool listens to the port 9090 and redirects messages to port 8080 at the localhost(i.e. to the same machine). Note: You may change these default settings using few command line arguments.

Usage : tcpmon.exe [-lp LISTEN_PORT] [-tp TARGET_PORT] [-th TARGET_HOST] [-f LOG_FILE]
e.g. tcpmon.exe -lp 9090 -tp 8080 -th localhost -f my_tcpmon.log

Since we are redirecting our messages to port 8080, this time we have to start the server listening to that port.
%axis2_http_server.exe -p8080

Alright now we are ready to sniff the wire content. Now what we have to do is start a client. The client samples are available at WSFC_HOME/bin/samples. I'll use the following. But try other samples as well.
%echo_blocking_addr.exe

OK now you see that your service invoke is successful and feel that the world is newer better. So please do open the tcpmon_traffic.log in WSFC_HOME/bin/tools using a text editor such as notepad, gedit or vi to see the wire content. Now you should see something like this.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
SENDING DATA..
/* sending time = 10:58:13*/
---------------------
POST /axis2/services/echo HTTP/1.1
User-Agent: Axis2/C
Content-Length: 512
Content-Type: application/soap+xml;charset=UTF-8
Host: localhost:9090

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>http://localhost:9090/axis2/services/echo</wsa:To>
<wsa:Action>http://ws.apache.org/axis2/c/samples/echoString</wsa:Action>
<wsa:MessageID>02973ea8-bb4f-1dc1-2693-000000000000</wsa:MessageID>
</soapenv:Header>
<soapenv:Body>
<ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/services/echo">
<text>Hello World!</text>
</ns1:echoString>
</soapenv:Body>
</soapenv:Envelope>

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
RETRIEVING DATA..
/* retrieving time = 10:58:13*/
/* time throughput = 0 sec(s)*/
---------------------
HTTP/1.1 200 OK
Content-Type: application/soap+xml;charset=UTF-8
Content-Length: 672

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://ws.apache.org/axis2/c/samples/echoString</wsa:Action>
<wsa:From>
<wsa:Address>http://localhost:9090/axis2/services/echo</wsa:Address>
</wsa:From>
<wsa:MessageID>02983114-bb4f-1dc1-3856-000000000000</wsa:MessageID>
<wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply">02973ea8-bb4f-1dc1-2693-000000000000</wsa:RelatesTo>
</soapenv:Header>
<soapenv:Body>
<ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/c/samples">
<text>Hello World!</text>
</ns1:echoString>
</soapenv:Body>
</soapenv:Envelope>


The SOAP envelope in the first portion of the file shows the request and the last SOAP envelope shows the response from the server.

No comments: