我有Spring boot server
,它的工作方式类似于proxy
。它是SOAP service
和SOAP client
。用户呼叫我的服务器上的soap服务,而我的服务器呼叫另一个soap服务。 Bouth服务使用一个WSDL
。我的服务器实现了WSDL
并充当客户端的服务器。我的服务器使用此WSDL
来向另一台服务器发出请求,并充当另一台服务器的客户端。
Client -> WSDL -> My server -> WSDL -> Another server
| |
|------same WSDL------|
我需要管理SOAP日志,但是有问题。例如,我可以将以下几行添加到logback:
<logger name="org.apache.cxf.services.MessageExchangePortType.REQ_IN" level="ERROR" />
<logger name="org.apache.cxf.services.MessageExchangePortType.RESP_IN" level="ERROR" />
<logger name="org.apache.cxf.services.MessageExchangePortType.REQ_OUT" level="INFO" />
<logger name="org.apache.cxf.services.MessageExchangePortType.RESP_OUT" level="INFO" />
但是通过这种方式,我可以管理传入和传出消息的日志。
因为我的服务和客户使用MessageExchangePortType
。
如何管理每个客户端/服务器日志?
这是客户端的实现:
@Bean(name = "MessageExchangeClient")
public MessageExchangePortType signingPortType() {
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
jaxWsProxyFactoryBean.setServiceClass(MessageExchangePortType.class);
jaxWsProxyFactoryBean.setAddress(host);
jaxWsProxyFactoryBean.getInInterceptors().add(new LoggingInInterceptor());
jaxWsProxyFactoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
jaxWsProxyFactoryBean.getOutInterceptors().add(new FaultOutInterceptor());
jaxWsProxyFactoryBean.getOutInterceptors().add(new FaultOutInterceptor());
return (MessageExchangePortType) jaxWsProxyFactoryBean.create();
}
这是服务器的实现:
Component
@Slf4j
@SchemaValidation(type = SchemaValidation.SchemaValidationType.IN)
public class MyEndpoint implements MessageExchangePortType {
并在配置中:
@Configuration
public class WebServiceConfiguration {
@Value("${server.path}")
private String path;
private final Bus bus;
private final MyEndpoint myEndpoint;
@Autowired
public WebServiceConfiguration(Bus bus, MyEndpoint myEndpoint) {
this.bus = bus;
this.myEndpoint= myEndpoint;
}
@Bean
Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, myEndpoint);
endpoint.getInInterceptors().add(new SAAJInInterceptor());
LoggingFeature loggingFeature = new LoggingFeature();
loggingFeature.setVerbose(true);
loggingFeature.setLogMultipart(true);
loggingFeature.setPrettyLogging(true);
endpoint.getFeatures().add(loggingFeature);
endpoint.publish(path);
return endpoint;
}
}
例如,我想禁用REQ_IN
登录客户端并在服务器上启用,但是如果我写:<logger name="org.apache.cxf.services.MessageExchangePortType.REQ_IN" level="ERROR" />
我将错误级别设置为客户端和服务器,因为MessageExchangePortType
使用客户端和服务器。
答案 0 :(得分:1)
使用您自己的org.apache.cxf.ext.logging.event.LogEventSender
类型并更改类别。在org.apache.cxf.ext.logging.slf4j.Slf4jEventSender
中查看您默认使用的实现,以了解如何实现该实现。