While calling soap service from spring integration how to add timeout? Below is the code where I'm calling a soap service using Ws.marshallingOutboundGateway().
@Bean
public IntegrationFlow flow() {
return flow ->
flow.handle(Ws.marshallingOutboundGateway(webServiceTemplate()).uri(someSOAPUrl));
};
}
@Bean
public WebServiceTemplate webServiceTemplate() throws Exception {
WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
R123Marshaller marshaller = new R123Marshaller();
marshaller.setContextPath("com.example.request.soap123");
webServiceTemplate.setMarshaller(marshaller);
Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller();
unmarshaller.setContextPath("com.example.request.soap123");
webServiceTemplate.setUnmarshaller(unmarshaller);
return webServiceTemplate;
}
Is there a way I can do something like below -
.handle(Http.outboundGateway(someURL, restTemplateConfig.restTemplate())
Here I have added timeout in the resttemplate that I've passed.
Use the HttpComponentsMessageSender
in the template, instead of the default
https://docs.spring.io/spring-ws/docs/current/reference/html/#_using_the_client_side_api
/**
* Sets the timeout until a connection is established. A value of 0 means <em>never</em> timeout.
*
* @param timeout the timeout value in milliseconds
* @see org.apache.http.params.HttpConnectionParams#setConnectionTimeout(org.apache.http.params.HttpParams, int)
*/
public void setConnectionTimeout(int timeout) {
if (timeout < 0) {
throw new IllegalArgumentException("timeout must be a non-negative value");
}
org.apache.http.params.HttpConnectionParams.setConnectionTimeout(getHttpClient().getParams(), timeout);
}
/**
* Set the socket read timeout for the underlying HttpClient. A value of 0 means <em>never</em> timeout.
*
* @param timeout the timeout value in milliseconds
* @see org.apache.http.params.HttpConnectionParams#setSoTimeout(org.apache.http.params.HttpParams, int)
*/
public void setReadTimeout(int timeout) {
if (timeout < 0) {
throw new IllegalArgumentException("timeout must be a non-negative value");
}
org.apache.http.params.HttpConnectionParams.setSoTimeout(getHttpClient().getParams(), timeout);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.