CXF日志SOAP输出
我无法记录来自服务器的传出SOAP消息。handleMessage方法不会按预期覆盖消息内容。如何将传出的SOAP存储到消息中CXF日志SOAP输出,soap,cxf,Soap,Cxf,我无法记录来自服务器的传出SOAP消息。handleMessage方法不会按预期覆盖消息内容。如何将传出的SOAP存储到消息中 public class OutgoingSoapInterceptor extends AbstractPhaseInterceptor<Message> { private static final Logger logger = LoggerFactory.getLogger(OutgoingSoapInterceptor.class.getN
public class OutgoingSoapInterceptor extends AbstractPhaseInterceptor<Message> {
private static final Logger logger = LoggerFactory.getLogger(OutgoingSoapInterceptor.class.getName());
public OutgoingSoapInterceptor ()
{
super(Phase.PRE_STREAM);
}
@Override
public void handleMessage(Message message) throws Fault {
logger.debug("outbound soap handleMessage");
OutputStream os = message.getContent ( OutputStream.class );
CacheAndWriteOutputStream cwos = new CacheAndWriteOutputStream ( os);
message.setContent ( OutputStream.class, cwos );
cwos.registerCallback ( new LoggingOutCallBack ( ) );
}
}
公共类OutgoingSoapInterceptor扩展AbstractPhaseInterceptor{
私有静态最终记录器Logger=LoggerFactory.getLogger(OutgoingSoapInterceptor.class.getName());
公共支出SOAPInterceptor()
{
超级(相位预流);
}
@凌驾
public void handleMessage(消息消息消息)引发错误{
debug(“出站soap handleMessage”);
OutputStream os=message.getContent(OutputStream.class);
CacheAndWriteOutStream cwos=新的CacheAndWriteOutStream(os);
message.setContent(OutputStream.class,cwos);
cwos.registerCallback(新的LoggingOutCallBack());
}
}
使用CXFloggininterceptor
和logginoutinterceptor
LogUtils.setLoggerClass(org.apache.cxf.common.logging.Log4jLogger.class);
yourService = new YourService(wsdlURL, SERVICE_NAME);
port = yourService.getServicePort();
Client client = ClientProxy.getClient(port);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
或者使用spring在
中配置拦截器
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<jaxws:endpoint ... />
</beans>
参见中的更多示例,这让我走上了正确的道路。在这个过程中,我遇到了这个系统属性:我不知道这个属性。我不知道它是cxf的标准还是自己的JBoss,日志输出会被截断。无论消息大小如何,我们如何记录完整的xml输入/输出消息?