Update web services documentation and samples

Closes gh-42887
This commit is contained in:
Phillip Webb 2024-10-25 17:57:14 -07:00
parent 2208c67f22
commit 39da14ea80
3 changed files with 9 additions and 8 deletions

View File

@ -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.

View File

@ -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();
} }
} }

View File

@ -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()
} }
} }