• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

capture request and response to/from webservice

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can we log request and response to/from a webservice.do i have to write the code in the webservice or do i need to implement another application for it.

I would prefer to do that in same webservice.Can someone help ?
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use '-Dweblogic.webservice.verbose=true' in WLS 8.1. or you can use the tools like tcpmon to capture explicitly.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aditi.

Considering you will be using JAX-RPC (or the new JAX-WS) or even Apache Axis, one way of logging your requests and responses is by implementing a Message Handler for that purpose. A Message Handler acts like a Servlet Filter, i.e., it intercepts your request before it reaches its destination (the endpoint) and intercepts the response before it is returned to the caller (the WS client). Both are very good times to log what is going back and forth.

You can write your Message Handler to use your favorite logging API, get the XML contents and post them to a log file.

I personally would recommend you to create a JAX-RPC (or JAX-WS) compliant Message Handler because that would make it reusable to any JAX-RPC compliant SOAP engine. And that means you could potentially use the same logging Message Handler on the client, on the server and on other applications. All you have to do is deploy it to the desired Web Service once it's complete.

Regards.
 
aditi ray
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.io.BufferedWriter;
import javax.xml.namespace.QName;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.rpc.handler.Handler;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.namespace.QName;
import java.util.Iterator;
import org.omg.CORBA.*;



public class messageHandler implements Handler
{



public void destroy()
{

}


public QName[] getHeaders()
{
//return null;
return handlerInfo.getHeaders();
}

public boolean handleFault(MessageContext arg0)
{

}

public boolean handleRequest(MessageContext arg0)
{

}

public boolean handleResponse(MessageContext arg0)
{

}

public void init(HandlerInfo arg0)
{
handlerInfo = arg0;
}
}

I have implemented the above class to get request and response but not sure how to invoke it through web service code.I am using weblogic 8.1.

Do i need to define in web.xml or there is any other way.Please help
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not in web.xml - it has nothing to do with servlet. You need to consult your Weblogic documentation about where handlers are declared. (For Axis, there is a deployment descriptor where this stuff goes, but Weblogic may work differently.)
 
Paulo Salgado
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aditi.

I'm not a Weblogic guy, but I was looking over the 8.1 docs and it seems it implements J2EE 1.3 and JAX-RPC 1.0. Being that the case, the method of deployment of Message Handlers is not mandated by the spec. See JAX-RPC 1.0 12.3.2. That changes for J2EE 1.4 when webservices.xml is used.

There seems to be some good docs for Weblogic though. Take a ook at this one, which guides you specifically on designing, building and deploying Message Handlers with Weblogic 8.1: "Creating SOAP Message Handlers to Intercept the SOAP Message"

And this one is the parent doc. Lots of info.

Hope it helps and don't forget to share the results of your implementation.

Regards.
 
reply
    Bookmark Topic Watch Topic
  • New Topic