2021-09-20 16:15:08 -07:00

40 lines
1.6 KiB
Plaintext

[[io.webservices]]
== Web Services
Spring Boot provides Web Services auto-configuration so that all you must do is define your `Endpoints`.
The {spring-webservices-docs}[Spring Web Services features] can be easily accessed with the `spring-boot-starter-webservices` module.
`SimpleWsdl11Definition` and `SimpleXsdSchema` beans can be automatically created for your WSDLs and XSDs respectively.
To do so, configure their location, as shown in the following example:
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
----
spring:
webservices:
wsdl-locations: "classpath:/wsdl"
----
[[io.webservices.template]]
=== Calling Web Services with WebServiceTemplate
If you need to call remote Web services from your application, you can use the {spring-webservices-docs}#client-web-service-template[`WebServiceTemplate`] class.
Since `WebServiceTemplate` instances often need to be customized before being used, Spring Boot does not provide any single auto-configured `WebServiceTemplate` bean.
It does, however, auto-configure a `WebServiceTemplateBuilder`, which can be used to create `WebServiceTemplate` instances when needed.
The following code shows a typical example:
[source,java,indent=0,subs="verbatim"]
----
include::{docs-java}/io/webservices/template/MyService.java[]
----
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:
[source,java,indent=0,subs="verbatim"]
----
include::{docs-java}/io/webservices/template/MyWebServiceTemplateConfiguration.java[]
----