在服务器java中拦截HTTP请求

发布于 2024-09-25 06:52:42 字数 232 浏览 0 评论 0原文

我需要实现类似过滤器或侦听器的东西,拦截 HTTP 请求并检索 HTTP 标头以用于各种目的。

我使用 Java、Jboss 应用服务器和 Web 服务。我希望这个过滤系统在 Web 服务调用之前执行 - 正在考虑各个方面,但它们不包含 HTTP 相关的内容。过滤后,应进行服务调用。

Jax-WS 处理程序也不适合我,因为它们只保存 SOAP 有效负载。

有什么想法吗?

提前致谢。

I need to implemented something like a filter or listener, that intercepts HTTP requests and retrieves the HTTP headers for various purposes.

I use Java, Jboss application server and web services. I want this filtering system to be performed prior to the Web Services call - was thinking about aspects but they do not hold the HTTP related stuff. After the filter, the service call should be carried out.

Jax-WS handlers don't work for me either as they only hold the SOAP payload.

Any ideas?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简美 2024-10-02 06:52:42

您不能创建一个 servlet 过滤器来拦截所有传入您的 Web 服务引擎的请求吗?如果您使用 Axis 或任何其他 SOAP 引擎,我希望您能够创建一个过滤器来拦截所有传入 SOAP 引擎提供的主 servlet 的请求。

 public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException,ServletException
  {
    HttpServletRequest httpRequest=(HttpServletRequest)request;
    HttpServletResponse httpResponse=(HttpServletResponse)response;
       Enumeration headerNames = httpRequest.getHeaderNames();
        while(headerNames.hasMoreElements()) {
          String headerName = (String)headerNames.nextElement();
          out.println(headerName);
          out.println(request.getHeader(headerName));
        }
       chain.doFilter(request,response);
}

can you not create a servlet filter which intercepts all the requests coming to your webservice engine? If you are using Axis or anyother SOAP engine, I hope you should be able to create a filter that intercepts all the requests coming to the main servlet that the SOAP engine provides.

 public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException,ServletException
  {
    HttpServletRequest httpRequest=(HttpServletRequest)request;
    HttpServletResponse httpResponse=(HttpServletResponse)response;
       Enumeration headerNames = httpRequest.getHeaderNames();
        while(headerNames.hasMoreElements()) {
          String headerName = (String)headerNames.nextElement();
          out.println(headerName);
          out.println(request.getHeader(headerName));
        }
       chain.doFilter(request,response);
}
雪花飘飘的天空 2024-10-02 06:52:42

使用 libpcap 和 Java 接口 jNetPcap

Use libpcap and the Java interface jNetPcap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文