记录肥皂请求和响应 - 春天

时间:2018-06-07 07:47:07

标签: spring-boot

我在代码中对系统进行外部SOAP调用。 我想记录这些调用的HTTP请求和响应。 我们有不同的调用SOAP的实现,如Spring WS,JAX RS。 所以,基本上我需要通过SOAP记录我们对这个外部系统发出的所有HTTP请求和响应。

1 个答案:

答案 0 :(得分:0)

我所做的是一个配置bean,您可以使用这样的env var启用或禁用:

@Configuration
@ConditionalOnProperty("soap.debug")
public class DebugSOAPConfig {

private static final Logger logger = LoggerFactory.getLogger(DebugSOAPConfig.class);

@Value("${soap.environment}")
private String soapEnv;

@PostConstruct
public void dumpXML() {
    logger.debug(String.format("Debugging SOAP Env: %s", soapEnv));
    System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
    System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
    System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
    System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
    System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold", "10000");
  }
}
相关问题