问题描述
我有一个通过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 :
资源
- (从这里开始)
- Writing a Handler in JAX-WS (start here)
- Handler example using JAXWS 2.0
- APIs
- Java API for XML-Based Web Services (JAX-WS) 2.0 specification
- APIs
javax.xml.ws.handler.Handler
javax.xml.ws.handler.LogicalHandler
javax.xml.ws.handler.soap.SOAPHandler
这篇关于JAX-WS servlet过滤器异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!