【发布时间】:2016-11-24 14:45:01
【问题描述】:
我有一个需要某种请求格式的网络服务。 当我发送无效的请求格式时,出现以下错误:
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"", local:"aaaa"). Expected elements are <{}xxx>,<{}yyy></faultstring>
发生这种情况时,我需要发送电子邮件。在这封电子邮件中,我需要传入的请求(我发送到 Web 服务的 XML)。
我尝试实现一个 CXF 拦截器:
public class ExceptionInterceptor extends AbstractSoapInterceptor {
/**
* Logger
*/
private final static Logger LOGGER = LoggerFactory.getLogger(ExceptionInterceptor.class);
/**
* Constructeur
*/
public ExceptionInterceptor() {
super(Phase.PRE_LOGICAL);
}
public void handleMessage(SoapMessage message) throws Fault {
Fault fault = (Fault) message.getContent(Exception.class);
Throwable ex = fault.getCause();
if (ex instanceof UnmarshalException) {
LOGGER.error("Error in incoming message", ex);
// TODO : send email
}
}
}
但是...我怎样才能在这里获得我发送到网络服务的原始消息? Apache CXF 拦截器的文档不多。 :(
提前致谢!
赫克
【问题讨论】:
标签: java xml apache web-services cxf