How to monitor messages using tcpmon in Axis2 dual channel web service invocation

Apache Axis2 client API provides the necessary methods to utilize a service using two transport channels. You can even send request through one transport (e.g:- HTTP) and get the response back via a different transport such as TCP.

setUseSeperateListener(boolean) method of org.apache.axis2.client.Options
class can be used to utilize a separate listener for your response.
If two separate HTTP transport channels are used for request and response, Axis2 starts a new HTTP listener at the client side to receive the incoming response message.

As most of web service developers know, Apache tcpmon can be used to monitor message flow between web service invocations. In one way messaging, it is quite straightforward.
You just need to configure tcpmon to listen in some port and direct the messages to the port where the web service is hosted. In client, port of the endpoint reference has to be changed to tcpmonitor listen port. That's all you have to do for monitoring messages in single channel invocation.

In this post, you can see how tcpmonitor is configured to use in dual channel invocation.

1. If you have not done it yet, download Apache tcpmon from here
Unzip the downloaded file and run build/tcpmon.bat {sh}

2. As I stated before, Axis2 starts a http listener at the client in dual channel invocation. Therefore, you need to configure Axis2.xml to redirect messages to tcpmon as follows.

Open AXIS2_HOME/conf/axis2.xml and locate to the following section.

<!-- ============================================ -->
<!-- Transport Ins -->
<!-- ============================================ -->
<transportReceiver name="http"
class="org.apache.axis2.transport.http.SimpleHTTPServer">
<parameter name="port">8080</parameter>
<!-- Here is the complete list of supported parameters (see example settings further below):
port: the port to listen on (default 6060)
hostname: if non-null, url prefix used in reply-to endpoint references (default null)
------------
-->
<parameter name="hostname">http://localhost:8090</parameter>
<!-- <parameter name="originServer">My-Server/1.1</parameter> -->
----------
</transportReceiver>

3. Note the highlighted elements in the above axis2.xml configuration. First you have to uncomment the hostname paramter <parameter name="hostname"> and specify a port which is not already listened in your system (e.g:- 8090).

In tcpmon, create a new listener with 8090 as the listen port and 8080 as the target port. With this configuration, the response messages receive to the reply-to endpoint reference are directed to 8090 tcpmon port and then those will be targeted to client HTTP listener port, 8080.



Now, you should be able to monitor the response flow in dual channel invocation.

Comments

Unknown said…
Charitha

Good post. I've got a slightly different approach: I've blogged it too.
rajika said…
Thanks for the great post machang!
stickerz said…
thanx aiya. much understandable.
Unknown said…
Your solution for a tricky problem also works for the Membrane SOAP Monitor.
Unknown said…
Hi Charitha,
---I am stuck with this---
I am trying to monitor the soap msgs using tcpmon and the transport layer used is HTTPS. I could see the soap request but for response it throws the following error
-----------------------------
Exception in thread "main" org.apache.axis2.AxisFault: The server localhost failed to respond with a valid HTTP response
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at tutorial.rampart.client.SecureServiceStub.add(SecureServiceStub.java:196)
at tutorial.rampart.client.SecureServiceCGClient.main(SecureServiceCGClient.java:36)
Caused by: org.apache.commons.httpclient.ProtocolException: The server localhost failed to respond with a valid HTTP response
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1987)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:550)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
... 9 more
----------------------------

could you please tell me how to set the transport receiver for https?

Thanks in advance
asi
Charitha said…
Hi asi,
As far as i know, you can't monitor https traffic using tcpmon. You could do this using WSO2 WSAS soap tracer component if your service is deployed on WSAS. Please download WSO2 WSAS from http://www.wso2.org and enable soap tracing. I do not know any other tool which can be used to monitor HTTPS traffic.

Regards
Charitha
Unknown said…
Hi Charitha -

I'm trying to use the Eclipse TCPMON plugin to monitor WebDAV requests to WAS7 (port 9080). I've tried several different Listener ports but always get "Waiting for Connection".
Any suggestions?

Thanks.

- Dave Levitt
Thank you dear

This is a vital news how to use the tcpmon tool.

I also tried or checked different blogs or sites to get an idea how to run it and track the SOAP message,but everybody is telling only the root area but you are genius you just told only 2 points, but it was a good points..

What I done. To Track SOAP Message using Axis2 , Webservice client.
1. dowloaded the tcpmon "tcpmon-1.0-bin" file from the site (you can google it for download with the file name, only 251KB size.
2. Extracted the rar file.

From here to down only for the users who use the web service client in Axis2.
3. In My application (same for all),
3.a. If you are not passing any ConfigurationContext as parameter while creating your stub object, that means you are using the internal axis2.xml only can find it in WebContent\WEB-INF\conf
OR
3.b. if you are passing an instance of Configuration context object while creating you stub object , that means you are using the axis2.xml from your external Axis2 folder only, that you can fine in your "axis2-1.2\conf" location.

4. Find the location where the tag
then give the command tcpmon.bat(windows) or tcpmon.sh(linux)
it will open a tcpmon window
choose the admin tab.

give any port address like 9090 or any port that address should be free in your system to the listener port.

listner option , give the target host name (the same what you are calling in your webservice client for to perform the action)
ex: - in my case location : http://org.aram.com:443/PVRS/services/AreaService
Target hostname = org.aram.com and Target Port is = 443

then click ADD button, will create a new window with listening to 9090 and the server location is org.aram.com with port 443.

6. Then back to the Axis2.xml file , give the same

443
and
http://org.aramco.com:9090


7. then edit your end point address in your client call like
ex:-
existing one : http://org.aram.com/........
new one : http://org.ara.com:9090/....
wen ever you perfom the operation the axis2.file will convert the call http://org.aram.com:9090 to htt://org.aram.com:443 mean while the tcpmon will get your request also.

8. in that created new tab you can see you SOAPMeddage Request/Reponse.

hop this will help you ..for more details mail me..i will be here to help you ..
email : sherafudheen.n.s@gmail.com

Popular posts from this blog

Working with HTTP multipart requests in soapUI

Common mistakes to avoid in WSO2 ESB - 1 - "org.apache.axis2.AxisFault: The system cannot infer the transport information from the URL"

How to deploy JSR181 annotated class in Apache Axis2