How to use TCP/IP monitor for web service

The TCP/IP monitor view in Rational Application developer lets you monitor HTTP traffic. It makes it easier to monitor the Web Service request and response. The basic idea is you create a tunnel for example the default HTTP port for WAS is 9080, and i want to monitor traffic on localhost:9080, so i did create a monitor for port localhost:80 and now whenever i make a request to localhost:80, the TCP/IP monitor will forward that request to localhost:9080 and also log it. This is same principle as that of Tcpmon


I wanted to try this feature so i used these steps.

  • In the TCP/IP montior view click on properties sub menu like this


  • On the next window i did create a monitor that will forward requests sent to localhost:8080 to localhost:9080 like this

    After creating the monitor start it, if its not already started.

  • Create a web service client using RAD, when you create the web service client, RAD copies the wsdl file in the META-INF/wsdl folder and this file has the service binding section, which has the URL for actual service. The Web Service client created by RAD reads URL of the service from wsdl to communicate with the service.

    @WebServiceClient(name = "HelloWebServiceService", targetNamespace = "http://services.webspherenotes.com/",
    wsdlLocation = "META-INF/wsdl/HelloWebServiceService.wsdl")
    public class HelloWebServiceService
    extends Service
    {

    private final static URL HELLOWEBSERVICESERVICE_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(com.webspherenotes.services.HelloWebServiceService.class.getName());

    static {
    URL url = null;
    try {

    url = com.webspherenotes.services.HelloWebServiceService.class.getResource("/META-INF/wsdl/HelloWebServiceService.wsdl");

    if (url == null) throw new MalformedURLException("/META-INF/wsdl/HelloWebServiceService.wsdl does not exist in the module.");
    } catch (MalformedURLException e) {
    logger.warning("Failed to create URL for the wsdl Location: 'META-INF/wsdl/HelloWebServiceService.wsdl', retrying as a local file");
    logger.warning(e.getMessage());
    }
    HELLOWEBSERVICESERVICE_WSDL_LOCATION = url;
    }

    public HelloWebServiceService(URL wsdlLocation, QName serviceName) {
    super(wsdlLocation, serviceName);
    }

    public HelloWebServiceService() {
    super(HELLOWEBSERVICESERVICE_WSDL_LOCATION, new QName("http://services.webspherenotes.com/", "HelloWebServiceService"));
    }

    /**
    *
    * @return
    * returns HelloWebService
    */
    @WebEndpoint(name = "HelloWebServicePort")
    public HelloWebService getHelloWebServicePort() {
    return super.getPort(new QName("http://services.webspherenotes.com/", "HelloWebServicePort"), HelloWebService.class);
    }

    /**
    *
    * @param features
    * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.
    Supported features not in the features parameter will have their default values.
    * @return
    * returns HelloWebService
    */
    @WebEndpoint(name = "HelloWebServicePort")
    public HelloWebService getHelloWebServicePort(WebServiceFeature... features) {
    return super.getPort(new QName("http://services.webspherenotes.com/", "HelloWebServicePort"), HelloWebService.class, features);
    }

    }

    In the static block of the HelloWebServiceService, it is reading the wsdl and using the URL for making request.


  • Now in order for TCP/IP monitor to monitor the traffic, we will have to change the value of the URL so that it goes through the port monitored by TCP/IP monitor. I changed the value to 80 like this


  • Now when i run the client i can see the traffic using TCP/IP monitor like this


No comments: