我有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使用客户端和服务器。
发布于 2018-10-19 07:39:15
实现您自己类型的org.apache.cxf.ext.logging.event.LogEventSender并更改类别。查看默认情况下正在使用的实现的org.apache.cxf.ext.logging.slf4j.Slf4jEventSender,了解如何实现该实现。
https://stackoverflow.com/questions/52851370
复制相似问题