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
-
Method Summary
Modifier and TypeMethodDescriptionadditionalCustomizers
(Collection<? extends WebServiceTemplateCustomizer> customizers) Add additionalWebServiceTemplateCustomizers
that should be applied to theWebServiceTemplate
.additionalCustomizers
(WebServiceTemplateCustomizer... customizers) Add additionalWebServiceTemplateCustomizers
that should be applied to theWebServiceTemplate
.additionalInterceptors
(Collection<? extends org.springframework.ws.client.support.interceptor.ClientInterceptor> interceptors) Add additionalClientInterceptors
that should be used with theWebServiceTemplate
.additionalInterceptors
(org.springframework.ws.client.support.interceptor.ClientInterceptor... interceptors) Add additionalClientInterceptors
that should be used with theWebServiceTemplate
.additionalMessageSenders
(Collection<? extends org.springframework.ws.transport.WebServiceMessageSender> messageSenders) Add additionalWebServiceMessageSenders
that should be used with theWebServiceTemplate
.additionalMessageSenders
(org.springframework.ws.transport.WebServiceMessageSender... messageSenders) Add additionalWebServiceMessageSenders
that should be used with theWebServiceTemplate
.org.springframework.ws.client.core.WebServiceTemplate
build()
Build a newWebServiceTemplate
instance and configure it using this builder.<T extends org.springframework.ws.client.core.WebServiceTemplate>
TBuild a newWebServiceTemplate
instance of the specified type and configure it using this builder.<T extends org.springframework.ws.client.core.WebServiceTemplate>
Tconfigure
(T webServiceTemplate) Configure the providedWebServiceTemplate
instance using this builder.customizers
(Collection<? extends WebServiceTemplateCustomizer> customizers) SetWebServiceTemplateCustomizers
that should be applied to theWebServiceTemplate
.customizers
(WebServiceTemplateCustomizer... customizers) SetWebServiceTemplateCustomizers
that should be applied to theWebServiceTemplate
.detectHttpMessageSender
(boolean detectHttpMessageSender) Set if a suitable HTTP-basedWebServiceMessageSender
should be detected based on the classpath.interceptors
(Collection<? extends org.springframework.ws.client.support.interceptor.ClientInterceptor> interceptors) Set theClientInterceptors
that should be used with theWebServiceTemplate
.interceptors
(org.springframework.ws.client.support.interceptor.ClientInterceptor... interceptors) Set theClientInterceptors
that should be used with theWebServiceTemplate
.messageSenders
(Collection<? extends org.springframework.ws.transport.WebServiceMessageSender> messageSenders) Sets theWebServiceMessageSenders
that should be used with theWebServiceTemplate
.messageSenders
(org.springframework.ws.transport.WebServiceMessageSender... messageSenders) Sets theWebServiceMessageSenders
that 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 theDestinationProvider
to use.setFaultMessageResolver
(org.springframework.ws.client.core.FaultMessageResolver faultMessageResolver) Set theFaultMessageResolver
to use.setMarshaller
(Marshaller marshaller) Set theMarshaller
to use to serialize messages.setTransformerFactoryClass
(Class<? extends TransformerFactory> transformerFactoryClass) Set theTransformerFactory
implementation to use.setUnmarshaller
(Unmarshaller unmarshaller) Set theUnmarshaller
to use to deserialize messages.setWebServiceMessageFactory
(org.springframework.ws.WebServiceMessageFactory messageFactory) Sets theWebServiceMessageFactory
to use for creating messages.
-
Constructor Details
-
WebServiceTemplateBuilder
-
-
Method Details
-
detectHttpMessageSender
Set if a suitable HTTP-basedWebServiceMessageSender
should be detected based on the classpath. Default istrue
.- Parameters:
detectHttpMessageSender
- if an HTTP-basedWebServiceMessageSender
should be detected- Returns:
- a new builder instance
- See Also:
-
messageSenders
public WebServiceTemplateBuilder messageSenders(org.springframework.ws.transport.WebServiceMessageSender... messageSenders) Sets theWebServiceMessageSenders
that 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 theWebServiceMessageSenders
that 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 additionalWebServiceMessageSenders
that 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 additionalWebServiceMessageSenders
that 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 theClientInterceptors
that 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 theClientInterceptors
that 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 additionalClientInterceptors
that 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 additionalClientInterceptors
that should be used with theWebServiceTemplate
.- Parameters:
interceptors
- the interceptors to add- Returns:
- a new builder instance
- See Also:
-
customizers
SetWebServiceTemplateCustomizers
that 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) SetWebServiceTemplateCustomizers
that 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 additionalWebServiceTemplateCustomizers
that 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 additionalWebServiceTemplateCustomizers
that 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 theWebServiceMessageFactory
to 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 theUnmarshaller
to use to deserialize messages.- Parameters:
unmarshaller
- the message unmarshaller- Returns:
- a new builder instance.
- See Also:
-
WebServiceTemplate.setUnmarshaller(Unmarshaller)
-
setMarshaller
Set theMarshaller
to 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 theFaultMessageResolver
to 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 theTransformerFactory
implementation 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 theDestinationProvider
to 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 newWebServiceTemplate
instance and configure it using this builder.- Returns:
- a configured
WebServiceTemplate
instance. - See Also:
-
build
public <T extends org.springframework.ws.client.core.WebServiceTemplate> T build(Class<T> webServiceTemplateClass) Build a newWebServiceTemplate
instance 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
WebServiceTemplate
instance. - See Also:
-
configure
public <T extends org.springframework.ws.client.core.WebServiceTemplate> T configure(T webServiceTemplate) Configure the providedWebServiceTemplate
instance using this builder.- Type Parameters:
T
- the type of web service template- Parameters:
webServiceTemplate
- theWebServiceTemplate
to configure- Returns:
- the web service template instance
- See Also:
-