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 ClientInterceptor> interceptors) Add additionalClientInterceptorsthat should be used with theWebServiceTemplate.additionalInterceptors(ClientInterceptor... interceptors) Add additionalClientInterceptorsthat should be used with theWebServiceTemplate.additionalMessageSenders(Collection<? extends WebServiceMessageSender> messageSenders) Add additionalWebServiceMessageSendersthat should be used with theWebServiceTemplate.additionalMessageSenders(WebServiceMessageSender... messageSenders) Add additionalWebServiceMessageSendersthat should be used with theWebServiceTemplate.build()Build a newWebServiceTemplateinstance and configure it using this builder.<T extends WebServiceTemplate>
TBuild a newWebServiceTemplateinstance of the specified type and configure it using this builder.<T extends 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 when one has not been specified.httpMessageSenderFactory(WebServiceMessageSenderFactory messageSenderFactory) Set theWebServiceMessageSenderFactorythat should be used to send HTTP messages.interceptors(Collection<? extends ClientInterceptor> interceptors) Set theClientInterceptorsthat should be used with theWebServiceTemplate.interceptors(ClientInterceptor... interceptors) Set theClientInterceptorsthat should be used with theWebServiceTemplate.messageSenders(Collection<? extends WebServiceMessageSender> messageSenders) Sets theWebServiceMessageSendersthat should be used with theWebServiceTemplate.messageSenders(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(DestinationProvider destinationProvider) Set theDestinationProviderto use.setFaultMessageResolver(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(WebServiceMessageFactory messageFactory) Sets theWebServiceMessageFactoryto use for creating messages.
-
Constructor Details
-
WebServiceTemplateBuilder
-
-
Method Details
-
httpMessageSenderFactory
public WebServiceTemplateBuilder httpMessageSenderFactory(WebServiceMessageSenderFactory messageSenderFactory) Set theWebServiceMessageSenderFactorythat should be used to send HTTP messages.- Parameters:
messageSenderFactory- theWebServiceMessageSenderFactoryto use- Returns:
- a new builder instance
- Since:
- 3.4.0
-
detectHttpMessageSender
Set if a suitable HTTP-basedWebServiceMessageSendershould be detected based on the classpath when one has not been specified. Default istrue.- Parameters:
detectHttpMessageSender- if an HTTP-basedWebServiceMessageSendershould be detected- Returns:
- a new builder instance
-
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 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(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 WebServiceMessageSender> messageSenders) Add additionalWebServiceMessageSendersthat should be used with theWebServiceTemplate.- Parameters:
messageSenders- the message senders to add- Returns:
- a new builder instance.
- See Also:
-
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
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
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 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:
-
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:
-
setWebServiceMessageFactory
public WebServiceTemplateBuilder setWebServiceMessageFactory(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:
-
setUnmarshaller
Set theUnmarshallerto use to deserialize messages.- Parameters:
unmarshaller- the message unmarshaller- Returns:
- a new builder instance.
- See Also:
-
setMarshaller
Set theMarshallerto use to serialize messages.- Parameters:
marshaller- the message marshaller- Returns:
- a new builder instance.
- See Also:
-
setFaultMessageResolver
Set theFaultMessageResolverto use.- Parameters:
faultMessageResolver- the fault message resolver to use- Returns:
- a new builder instance.
- See Also:
-
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:
-
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
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:
-
build
Build a newWebServiceTemplateinstance and configure it using this builder.- Returns:
- a configured
WebServiceTemplateinstance. - See Also:
-
build
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
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:
-