Update web services documentation and samples
Closes gh-42887
This commit is contained in:
parent
2208c67f22
commit
39da14ea80
|
|
@ -30,6 +30,8 @@ The following code shows a typical example:
|
||||||
include-code::MyService[]
|
include-code::MyService[]
|
||||||
|
|
||||||
By default, `WebServiceTemplateBuilder` detects a suitable HTTP-based `WebServiceMessageSender` using the available HTTP client libraries on the classpath.
|
By default, `WebServiceTemplateBuilder` detects a suitable HTTP-based `WebServiceMessageSender` using the available HTTP client libraries on the classpath.
|
||||||
You can also customize read and connection timeouts as follows:
|
You can also customize read and connection timeouts for an individual builder as follows:
|
||||||
|
|
||||||
include-code::MyWebServiceTemplateConfiguration[]
|
include-code::MyWebServiceTemplateConfiguration[]
|
||||||
|
|
||||||
|
TIP: You can also change the xref:io/rest-client.adoc#io.rest-client.clienthttprequestfactory.configuration[global HTTP client configuration] used if not specific template customization code is applied.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import org.springframework.boot.webservices.client.WebServiceTemplateBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.ws.client.core.WebServiceTemplate;
|
import org.springframework.ws.client.core.WebServiceTemplate;
|
||||||
import org.springframework.ws.transport.WebServiceMessageSender;
|
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
public class MyWebServiceTemplateConfiguration {
|
public class MyWebServiceTemplateConfiguration {
|
||||||
|
|
@ -34,8 +33,8 @@ public class MyWebServiceTemplateConfiguration {
|
||||||
ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.defaults()
|
ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.defaults()
|
||||||
.withConnectTimeout(Duration.ofSeconds(2))
|
.withConnectTimeout(Duration.ofSeconds(2))
|
||||||
.withReadTimeout(Duration.ofSeconds(2));
|
.withReadTimeout(Duration.ofSeconds(2));
|
||||||
WebServiceMessageSender sender = WebServiceMessageSenderFactory.http(settings).getWebServiceMessageSender();
|
builder.httpMessageSenderFactory(WebServiceMessageSenderFactory.http(settings));
|
||||||
return builder.messageSenders(sender).build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ class MyWebServiceTemplateConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
fun webServiceTemplate(builder: WebServiceTemplateBuilder): WebServiceTemplate {
|
fun webServiceTemplate(builder: WebServiceTemplateBuilder): WebServiceTemplate {
|
||||||
val settings = ClientHttpRequestFactorySettings.defaults()
|
val settings = ClientHttpRequestFactorySettings.defaults()
|
||||||
.withConnectTimeout(Duration.ofSeconds(2))
|
.withConnectTimeout(Duration.ofSeconds(2))
|
||||||
.withReadTimeout(Duration.ofSeconds(2));
|
.withReadTimeout(Duration.ofSeconds(2))
|
||||||
val sender = WebServiceMessageSenderFactory.http(settings).getWebServiceMessageSender();
|
builder.httpMessageSenderFactory(WebServiceMessageSenderFactory.http(settings))
|
||||||
return builder.messageSenders(sender).build();
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue