Class WebServiceTemplateBuilder

java.lang.Object
org.springframework.boot.webservices.client.WebServiceTemplateBuilder

public class WebServiceTemplateBuilder extends Object
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 Details

  • Method Details

    • detectHttpMessageSender

      public WebServiceTemplateBuilder detectHttpMessageSender(boolean detectHttpMessageSender)
      Set if a suitable HTTP-based WebServiceMessageSender should be detected based on the classpath. Default is true.
      Parameters:
      detectHttpMessageSender - if an HTTP-based WebServiceMessageSender should be detected
      Returns:
      a new builder instance
      See Also:
    • messageSenders

      public WebServiceTemplateBuilder messageSenders(org.springframework.ws.transport.WebServiceMessageSender... messageSenders)
      Sets the WebServiceMessageSenders that should be used with the WebServiceTemplate. Setting this value will replace any previously defined message senders, including the HTTP-based message sender, if any. Consider using additionalMessageSenders(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 the WebServiceMessageSenders that should be used with the WebServiceTemplate. Setting this value will replace any previously defined message senders, including the HTTP-based message sender, if any. Consider using additionalMessageSenders(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 additional WebServiceMessageSenders that should be used with the WebServiceTemplate.
      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 additional WebServiceMessageSenders that should be used with the WebServiceTemplate.
      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 the ClientInterceptors that should be used with the WebServiceTemplate. 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 the ClientInterceptors that should be used with the WebServiceTemplate. 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 additional ClientInterceptors that should be used with the WebServiceTemplate.
      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 additional ClientInterceptors that should be used with the WebServiceTemplate.
      Parameters:
      interceptors - the interceptors to add
      Returns:
      a new builder instance
      See Also:
    • customizers

      public WebServiceTemplateBuilder customizers(WebServiceTemplateCustomizer... customizers)
      Set WebServiceTemplateCustomizers that should be applied to the WebServiceTemplate. 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)
      Set WebServiceTemplateCustomizers that should be applied to the WebServiceTemplate. 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

      public WebServiceTemplateBuilder additionalCustomizers(WebServiceTemplateCustomizer... customizers)
      Add additional WebServiceTemplateCustomizers that should be applied to the WebServiceTemplate. 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 additional WebServiceTemplateCustomizers that should be applied to the WebServiceTemplate. 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

      public WebServiceTemplateBuilder setCheckConnectionForFault(boolean checkConnectionForFault)
      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

      public WebServiceTemplateBuilder setCheckConnectionForError(boolean checkConnectionForError)
      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 the WebServiceMessageFactory 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

      public WebServiceTemplateBuilder setUnmarshaller(Unmarshaller unmarshaller)
      Set the Unmarshaller to use to deserialize messages.
      Parameters:
      unmarshaller - the message unmarshaller
      Returns:
      a new builder instance.
      See Also:
      • WebServiceTemplate.setUnmarshaller(Unmarshaller)
    • setMarshaller

      public WebServiceTemplateBuilder setMarshaller(Marshaller marshaller)
      Set the Marshaller 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 the FaultMessageResolver 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 the TransformerFactory implementation to use.
      Parameters:
      transformerFactoryClass - the transformer factory implementation to use
      Returns:
      a new builder instance.
      See Also:
      • TransformerObjectSupport.setTransformerFactoryClass(Class)
    • setDefaultUri

      public WebServiceTemplateBuilder setDefaultUri(String defaultUri)
      Set the default URI to be used on operations that do not have a URI parameter. Typically, either this property is set, or setDestinationProvider(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 the DestinationProvider to use. Typically, either this property is set, or setDefaultUri(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 new WebServiceTemplate 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 new WebServiceTemplate 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 provided WebServiceTemplate instance using this builder.
      Type Parameters:
      T - the type of web service template
      Parameters:
      webServiceTemplate - the WebServiceTemplate to configure
      Returns:
      the web service template instance
      See Also: