使用WebFilter从XML获取请求参数

时间:2022-08-22 17:45:33

I´m developing a Web Service, using Glassfish, using SOAP. I have several web methods, and I want to get introduce my webmethod name and his parameters to http head request.

我正在使用Glass开发使用Glassfish的Web服务。我有几个Web方法,我想将我的webmethod名称及其参数介绍给http head请求。

For example:

例如:

I have this path:

我有这条道路:

context: WebServices

context:WebServices

webMethod: makeSomething

webMethod:makeSomething

parameters:a=2

参数:a = 2

So I create a class named ProfilingFilter:

所以我创建了一个名为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);
    }

}

It´s possible to use servlet response or servlet request to get this information?

可以使用servlet响应或servlet请求来获取此信息吗?

If not, How can I do this?

如果没有,我该怎么做?

1 个解决方案

#1


0  

You will need to access the HTTP request body. There is only one caveat: You can read a stream only once which means you will have to do some tricks in order to keep the SOAP request working. Take a look here:

您需要访问HTTP请求正文。只有一点需要注意:您只能读取一次流,这意味着您必须做一些技巧才能保持SOAP请求的正常运行。看看这里:

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

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

This example covers reading a HTTP request and then passing the original data down the filter chain.

此示例包括读取HTTP请求,然后将原始数据传递到过滤器链中。

HTH, Mark

HTH,马克

#1


0  

You will need to access the HTTP request body. There is only one caveat: You can read a stream only once which means you will have to do some tricks in order to keep the SOAP request working. Take a look here:

您需要访问HTTP请求正文。只有一点需要注意:您只能读取一次流,这意味着您必须做一些技巧才能保持SOAP请求的正常运行。看看这里:

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

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

This example covers reading a HTTP request and then passing the original data down the filter chain.

此示例包括读取HTTP请求,然后将原始数据传递到过滤器链中。

HTH, Mark

HTH,马克