请教使用WebService CXF如何用自定义拦截器获取报文
2016-01-18 · 知道合伙人数码行家
知道合伙人数码行家
向TA提问 私信TA
package com.gosophia.metadataEngine.webservice.interceptor;
import javax.xml.ws.WebServiceException;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*继承一个拦截器类
*/
public class ErrorInterceptor extends AbstractPhaseInterceptor<Message>{
public ErrorInterceptor(String phase) {
super(phase);
}
public ErrorInterceptor(){
super(Phase.RECEIVE);
}
public void handleMessage(Message arg0) throws Fault {
}
//出现错误输出错误信息和栈信息
public void handleFault(Message message) {
Logger logger = LoggerFactory.getLogger(getClass());
Exception exeption=message.getContent(Exception.class);
logger.error(exeption.getMessage(),exeption);
}
}
配置拦截器