Sunday, July 12, 2015

Create a Apache Axis2 web service using eclipse and monitor requests / responses using TCPMon



This blog post will guide you to create a Apache Axis2 web service and a client plus to monitor the requests and responses via TCPMon.



Step 1 - Create a axis2 web service and client


I found this descriptive blog post which guides you on how to create a axis2 web service using eclipse and also create a client to consume the service. After creating the service and the client lets move to the next step.


Step 2 - Run TCPMon



TCPMon can be found in almost all the WSO2 products here is the link to download WSO2 Application Server. After downloading the WSO2 AS extract it to a desired location. Then go to {WSO2ASHome}/bin folder.

Run "tcpmon.bat" file if your using Windows as the OS or run the "tcpmon.sh" if you are on a Linux distro.

Step 3 - Create a listener in TCPMon


By creating a listener we can monitor the requests and responses that flows between the web service and client. This is where TCPMon comes in to play.

Add the below settings in TCPMon – Admin section to set up a listener

  1. Listen Port# = 8585(Port which the TCPMon will listen to)
  2. "Act as a.." section = Select “Listener” radio button
  3. Target Host-name = 127.0.0.1 (tomcat server host ip)
  4. Target port = 8080 (the port which the tomcat server is utilizing)


You can also add proxy support and/or simulate a slow connection scenario. For this demonstration I have added a time delay to simulate a slow network (refer below image). After you are done with the settings click on “Add”.




Step 4 - Modify the client stub class


Now that we set up a listener lets point the client to the listener port. Before the configuration change make sure the created server and client is working. Next,in your client code simply pass the endpoint to the constructor of the stub class and your ready to go. You can set your desired endpoint as shown in the below figure. Line number 12 if you are using the soap11 endpoint or line number 13 if you are using hoping to use soap12 endpoint.





Step 5 - View requests/responses in TCPMon


Run the client application and go to the TCPMon you can see the requests and responses.
Below are couple of screen shots of TCPMon. Note that the "Elapsed Time" is a bit long because I configured a slow connection.

Without slow simulation


With slow simulation



This way you can monitor and simulate different scenarios to check your web service and how the client will consume it.







No comments:

Post a Comment