请教使用WebService CXF如何用自定义拦截器获取报文
现在拦截器已经配置好了,客户端调用服务端接口的时候也能进入到拦截器,请问在自己定义的拦截器里怎样获取报文信息?信息~ --------------------编程问答-------------------- 自己帮自己顶一下! --------------------编程问答-------------------- 上去上去上去上去 --------------------编程问答-------------------- --------------------编程问答-------------------- 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);
}
}
配置拦截器
<jaxws:endpoint id="dataViewWebServiceEP" address="/DataViewWebService">
<jaxws:implementor ref="dataViewWebService" />
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
<bean class="com.gosophia.metadataEngine.webservice.interceptor.ErrorInterceptor"></bean>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<!-- 输出日志 -->
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>
</jaxws:outInterceptors>
</jaxws:endpoint>
你们为什么不百度呢 一大把 --------------------编程问答-------------------- http://cxf.apache.org/docs/interceptors.html --------------------编程问答-------------------- public void handleMessage(Message arg0) throws Fault {
//获取webservice的入参
List<Object> result = MessageContentsList.getContentsList(message);
}
补充:Java , Java EE