Class WebServiceTemplateBuilder
java.lang.Object
org.springframework.boot.webservices.client.WebServiceTemplateBuilder
Builder that can be used to configure and create a
WebServiceTemplate. Provides
convenience methods to register message senders, client interceptors and
customizers.
By default the built WebServiceTemplate uses the most suitable HTTP-based
WebServiceMessageSender, call detectHttpMessageSender(false) if you prefer to keep the default. In a typical
auto-configured Spring Boot application this builder is available as a bean and can be
injected whenever a WebServiceTemplate is needed.
- Since:
- 2.1.0
- Author:
- Dmytro Nosan, Stephane Nicoll
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadditionalCustomizers(Collection<? extends WebServiceTemplateCustomizer> customizers) Add additionalWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate.additionalCustomizers(WebServiceTemplateCustomizer... customizers) Add additionalWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate.additionalInterceptors(Collection<? extends org.springframework.ws.client.support.interceptor.ClientInterceptor> interceptors) Add additionalClientInterceptorsthat should be used with theWebServiceTemplate.additionalInterceptors(org.springframework.ws.client.support.interceptor.ClientInterceptor... interceptors) Add additionalClientInterceptorsthat should be used with theWebServiceTemplate.additionalMessageSenders(Collection<? extends org.springframework.ws.transport.WebServiceMessageSender> messageSenders) Add additionalWebServiceMessageSendersthat should be used with theWebServiceTemplate.additionalMessageSenders(org.springframework.ws.transport.WebServiceMessageSender... messageSenders) Add additionalWebServiceMessageSendersthat should be used with theWebServiceTemplate.org.springframework.ws.client.core.WebServiceTemplatebuild()Build a newWebServiceTemplateinstance and configure it using this builder.<T extends org.springframework.ws.client.core.WebServiceTemplate>
TBuild a newWebServiceTemplateinstance of the specified type and configure it using this builder.<T extends org.springframework.ws.client.core.WebServiceTemplate>
Tconfigure(T webServiceTemplate) Configure the providedWebServiceTemplateinstance using this builder.customizers(Collection<? extends WebServiceTemplateCustomizer> customizers) SetWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate.customizers(WebServiceTemplateCustomizer... customizers) SetWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate.detectHttpMessageSender(boolean detectHttpMessageSender) Set if a suitable HTTP-basedWebServiceMessageSendershould be detected based on the classpath.interceptors(Collection<? extends org.springframework.ws.client.support.interceptor.ClientInterceptor> interceptors) Set theClientInterceptorsthat should be used with theWebServiceTemplate.interceptors(org.springframework.ws.client.support.interceptor.ClientInterceptor... interceptors) Set theClientInterceptorsthat should be used with theWebServiceTemplate.messageSenders(Collection<? extends org.springframework.ws.transport.WebServiceMessageSender> messageSenders) Sets theWebServiceMessageSendersthat should be used with theWebServiceTemplate.messageSenders(org.springframework.ws.transport.WebServiceMessageSender... messageSenders) Sets theWebServiceMessageSendersthat should be used with theWebServiceTemplate.setCheckConnectionForError(boolean checkConnectionForError) Indicates whether the connection should be checked for error indicators (true), or whether these should be ignored (false).setCheckConnectionForFault(boolean checkConnectionForFault) Indicates whether the connection should be checked for fault indicators (true), or whether we should rely on the message only (false).setDefaultUri(String defaultUri) Set the default URI to be used on operations that do not have a URI parameter.setDestinationProvider(org.springframework.ws.client.support.destination.DestinationProvider destinationProvider) Set theDestinationProviderto use.setFaultMessageResolver(org.springframework.ws.client.core.FaultMessageResolver faultMessageResolver) Set theFaultMessageResolverto use.setMarshaller(Marshaller marshaller) Set theMarshallerto use to serialize messages.setTransformerFactoryClass(Class<? extends TransformerFactory> transformerFactoryClass) Set theTransformerFactoryimplementation to use.setUnmarshaller(Unmarshaller unmarshaller) Set theUnmarshallerto use to deserialize messages.setWebServiceMessageFactory(org.springframework.ws.WebServiceMessageFactory messageFactory) Sets theWebServiceMessageFactoryto use for creating messages.
-
Constructor Details
-
WebServiceTemplateBuilder
-
-
Method Details
-
detectHttpMessageSender
Set if a suitable HTTP-basedWebServiceMessageSendershould be detected based on the classpath. Default istrue.- Parameters:
detectHttpMessageSender- if an HTTP-basedWebServiceMessageSendershould be detected- Returns:
- a new builder instance
- See Also:
-
messageSenders
public WebServiceTemplateBuilder messageSenders(org.springframework.ws.transport.WebServiceMessageSender... messageSenders) Sets theWebServiceMessageSendersthat should be used with theWebServiceTemplate. Setting this value will replace any previously defined message senders, including the HTTP-based message sender, if any. Consider usingadditionalMessageSenders(WebServiceMessageSender...)to keep it with user-defined message senders.- Parameters:
messageSenders- the message senders to set- Returns:
- a new builder instance.
- See Also:
-
messageSenders
public WebServiceTemplateBuilder messageSenders(Collection<? extends org.springframework.ws.transport.WebServiceMessageSender> messageSenders) Sets theWebServiceMessageSendersthat should be used with theWebServiceTemplate. Setting this value will replace any previously defined message senders, including the HTTP-based message sender, if any. Consider usingadditionalMessageSenders(Collection)to keep it with user-defined message senders.- Parameters:
messageSenders- the message senders to set- Returns:
- a new builder instance.
- See Also:
-
additionalMessageSenders
public WebServiceTemplateBuilder additionalMessageSenders(org.springframework.ws.transport.WebServiceMessageSender... messageSenders) Add additionalWebServiceMessageSendersthat should be used with theWebServiceTemplate.- Parameters:
messageSenders- the message senders to add- Returns:
- a new builder instance.
- See Also:
-
additionalMessageSenders
public WebServiceTemplateBuilder additionalMessageSenders(Collection<? extends org.springframework.ws.transport.WebServiceMessageSender> messageSenders) Add additionalWebServiceMessageSendersthat should be used with theWebServiceTemplate.- Parameters:
messageSenders- the message senders to add- Returns:
- a new builder instance.
- See Also:
-
interceptors
public WebServiceTemplateBuilder interceptors(org.springframework.ws.client.support.interceptor.ClientInterceptor... interceptors) Set theClientInterceptorsthat should be used with theWebServiceTemplate. Setting this value will replace any previously defined interceptors.- Parameters:
interceptors- the interceptors to set- Returns:
- a new builder instance
- See Also:
-
interceptors
public WebServiceTemplateBuilder interceptors(Collection<? extends org.springframework.ws.client.support.interceptor.ClientInterceptor> interceptors) Set theClientInterceptorsthat should be used with theWebServiceTemplate. Setting this value will replace any previously defined interceptors.- Parameters:
interceptors- the interceptors to set- Returns:
- a new builder instance
- See Also:
-
additionalInterceptors
public WebServiceTemplateBuilder additionalInterceptors(org.springframework.ws.client.support.interceptor.ClientInterceptor... interceptors) Add additionalClientInterceptorsthat should be used with theWebServiceTemplate.- Parameters:
interceptors- the interceptors to add- Returns:
- a new builder instance
- See Also:
-
additionalInterceptors
public WebServiceTemplateBuilder additionalInterceptors(Collection<? extends org.springframework.ws.client.support.interceptor.ClientInterceptor> interceptors) Add additionalClientInterceptorsthat should be used with theWebServiceTemplate.- Parameters:
interceptors- the interceptors to add- Returns:
- a new builder instance
- See Also:
-
customizers
SetWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.- Parameters:
customizers- the customizers to set- Returns:
- a new builder instance
- See Also:
-
customizers
public WebServiceTemplateBuilder customizers(Collection<? extends WebServiceTemplateCustomizer> customizers) SetWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.- Parameters:
customizers- the customizers to set- Returns:
- a new builder instance
- See Also:
-
additionalCustomizers
Add additionalWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate. Customizers are applied in the order that they were added after builder configuration has been applied.- Parameters:
customizers- the customizers to add- Returns:
- a new builder instance
- See Also:
-
additionalCustomizers
public WebServiceTemplateBuilder additionalCustomizers(Collection<? extends WebServiceTemplateCustomizer> customizers) Add additionalWebServiceTemplateCustomizersthat should be applied to theWebServiceTemplate. Customizers are applied in the order that they were added after builder configuration has been applied.- Parameters:
customizers- the customizers to add- Returns:
- a new builder instance
- See Also:
-
setCheckConnectionForFault
Indicates whether the connection should be checked for fault indicators (true), or whether we should rely on the message only (false).- Parameters:
checkConnectionForFault- whether to check for fault indicators- Returns:
- a new builder instance.
- See Also:
-
WebServiceTemplate.setCheckConnectionForFault(boolean)
-
setCheckConnectionForError
Indicates whether the connection should be checked for error indicators (true), or whether these should be ignored (false).- Parameters:
checkConnectionForError- whether to check for error indicators- Returns:
- a new builder instance.
- See Also:
-
WebServiceTemplate.setCheckConnectionForError(boolean)
-
setWebServiceMessageFactory
public WebServiceTemplateBuilder setWebServiceMessageFactory(org.springframework.ws.WebServiceMessageFactory messageFactory) Sets theWebServiceMessageFactoryto use for creating messages.- Parameters:
messageFactory- the message factory to use for creating messages- Returns:
- a new builder instance.
- See Also:
-
WebServiceAccessor.setMessageFactory(WebServiceMessageFactory)
-
setUnmarshaller
Set theUnmarshallerto use to deserialize messages.- Parameters:
unmarshaller- the message unmarshaller- Returns:
- a new builder instance.
- See Also:
-
WebServiceTemplate.setUnmarshaller(Unmarshaller)
-
setMarshaller
Set theMarshallerto use to serialize messages.- Parameters:
marshaller- the message marshaller- Returns:
- a new builder instance.
- See Also:
-
WebServiceTemplate.setMarshaller(Marshaller)
-
setFaultMessageResolver
public WebServiceTemplateBuilder setFaultMessageResolver(org.springframework.ws.client.core.FaultMessageResolver faultMessageResolver) Set theFaultMessageResolverto use.- Parameters:
faultMessageResolver- the fault message resolver to use- Returns:
- a new builder instance.
- See Also:
-
WebServiceTemplate.setFaultMessageResolver(FaultMessageResolver)
-
setTransformerFactoryClass
public WebServiceTemplateBuilder setTransformerFactoryClass(Class<? extends TransformerFactory> transformerFactoryClass) Set theTransformerFactoryimplementation to use.- Parameters:
transformerFactoryClass- the transformer factory implementation to use- Returns:
- a new builder instance.
- See Also:
-
TransformerObjectSupport.setTransformerFactoryClass(Class)
-
setDefaultUri
Set the default URI to be used on operations that do not have a URI parameter. Typically, either this property is set, orsetDestinationProvider(DestinationProvider), but not both.- Parameters:
defaultUri- the destination provider URI to be used on operations that do not have a URI parameter.- Returns:
- a new builder instance.
- See Also:
-
setDestinationProvider
public WebServiceTemplateBuilder setDestinationProvider(org.springframework.ws.client.support.destination.DestinationProvider destinationProvider) Set theDestinationProviderto use. Typically, either this property is set, orsetDefaultUri(String), but not both.- Parameters:
destinationProvider- the destination provider to be used on operations that do not have a URI parameter.- Returns:
- a new builder instance.
- See Also:
-
WebServiceTemplate.setDestinationProvider(DestinationProvider)
-
build
public org.springframework.ws.client.core.WebServiceTemplate build()Build a newWebServiceTemplateinstance and configure it using this builder.- Returns:
- a configured
WebServiceTemplateinstance. - See Also:
-
build
public <T extends org.springframework.ws.client.core.WebServiceTemplate> T build(Class<T> webServiceTemplateClass) Build a newWebServiceTemplateinstance of the specified type and configure it using this builder.- Type Parameters:
T- the type of web service template- Parameters:
webServiceTemplateClass- the template type to create- Returns:
- a configured
WebServiceTemplateinstance. - See Also:
-
configure
public <T extends org.springframework.ws.client.core.WebServiceTemplate> T configure(T webServiceTemplate) Configure the providedWebServiceTemplateinstance using this builder.- Type Parameters:
T- the type of web service template- Parameters:
webServiceTemplate- theWebServiceTemplateto configure- Returns:
- the web service template instance
- See Also:
-