JAX-WS servlet过滤器异常 [英] JAX-WS servlet filter exceptions

查看:201
本文介绍了JAX-WS servlet过滤器异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过SOAP进行通信的客户端/服务器应用程序。服务器端应用程序是一个Java EE应用程序,它使用JAX-WS公开Web服务。我有一个servlet过滤器设置来在调用服务之前执行某些检查。

I have a client/server application that communicates via SOAP. The server-side application is a Java EE app that exposes web services using JAX-WS. I have a servlet filter setup to perform certain checks before a service is invoked.

除异常处理外,这一切都运行良好。如果我从过滤器中抛出异常,它将作为通用服务器异常返回到客户端。我需要找到一种方法来传播包含特定消息的自定义异常,以便客户端可以向用户显示消息。

This is all working pretty well, except for exception handling. If I throw an exception from the filter, it gets returned to the client as a generic server exception. I need to find a way to propagate a custom exception containing a specific message, so the client can display the message to the user.

有什么洞察力?

推荐答案

servlet过滤器并不是真的如果你想在SOAP响应中发送异常,那么正确的工具我会考虑使用JAX-WS处理程序来验证传入的消息(JAX-WS处理程序在某种程度上是JAX-WS服务的过滤器对Servlet的作用)。

A servlet filter isn't really the right tool if you want to send the exception in a SOAP response and I would consider using a JAX-WS handler for the verification of incoming messages instead (JAX-WS handlers are somehow to JAX-WS services what Filters are to Servlets).

Frmo 在JAX-WS SOAPHandlers中使用标头


JAX-WS处理程序



除了支持web
服务开发之外,JAX-WS
框架(用于创建基于SOAP的
的最新Java编程
语言API) Web服务和Web服务
consumer)还提供了一个处理程序
框架。处理程序提供了
来检查和操作传入或
传出SOAP消息(在
客户端和服务器端)。他们
充当强大的消息拦截器
,它可以执行一系列函数
,例如消息转换,
内容过滤,跟踪等。在
的事实中,处理程序是通常在
运行时环境中用于实现web
服务和SOAP规范,如
,如WS-Security,WS-ReliableMessaging,
等.JAX-WS处理程序类似于
EJB拦截器或servlet过滤器。
处理程序,如拦截器和
过滤器,鼓励开发人员按
模式跟随

JAX-WS Handlers

In addition to support for web services development, the JAX-WS framework (the latest Java programming language API for creating SOAP-based web services and web service consumers) also provides a handler framework. Handlers provide a means to inspect and manipulate incoming or outgoing SOAP messages (on both the client as well as server side). They act as powerful message interceptors that can perform an array of functions such as message transformation, content filtering, tracking, etc. In fact, handlers are often used in runtime environments to implement web service and SOAP specifications such as WS-Security, WS-ReliableMessaging, etc. JAX-WS handlers are similar to EJB interceptors or servlet filters. Handlers, like interceptors and filters, encourage developers to follow the chain of responsibility pattern.



资源



查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆