【发布时间】:2019-06-24 07:22:18
【问题描述】:
我正在使用弹簧靴。我已经为 SOAP Web 服务编写了一个 ClientInterceptor,我想记录我发送请求的 URL,我想在 handleResponse 方法中进行。但是我找不到办法做到这一点。是否可以?任何帮助都会很棒。
public class SoapClientHttpRequestInterceptor implements ClientInterceptor {
@Override
public boolean handleResponse(MessageContext messageContext) throws WebServiceClientException {
// I would like to get the URL and log it here.
}
}
我创建 restTemplate 的方式
@Bean
@Qualifier("testRestTemplate")
public RestTemplate testRestTemplate() {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setOutputStreaming(false);
ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(requestFactory);
RestTemplate restTemplate = new RestTemplate(factory);
restTemplate.setInterceptors(Collections.singletonList(restClientHttpRequestInterceptor));
restTemplate.setErrorHandler(testErrorHandler);
restTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
return restTemplate;
}
【问题讨论】:
标签: spring spring-boot soap resttemplate