Get query parameters from XML using WebFilter

I am developing a web service using Glassfish using SOAP. I have several web methods, and I want to provide my web method name and its parameters for requesting an HTTP header.

For example:

I have this way:

context : WebServices

webMethod : makeSomething

Parameters : a = 2

So, I create a class called ProfilingFilter:

@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, javax.servlet.ServletException { if (request.getContentLength() != -1 && context != null) { ((HttpServletResponse) response).addHeader("Operation", -->PATH+PARAMETERS); // ((HttpServletResponse) response).addHeader("Operation", -->makeSomething?a=2); } } 

Can I use a servlet or servlet request to get this information?

If not, how to do it?

+8
java web-services servlets webmethod
source share
1 answer

You will need to access the body of the HTTP request. There is only one caveat: you can read a stream only once, which means you will need to do some tricks to save a SOAP request. Look at here:

http://wetfeetblog.com/servlet-filer-to-log-request-and-response-details-and-payload/431

This example reads an HTTP request and then passes the raw data through a filter chain.

HTH, Mark

0
source share

All Articles