Upgrade to Java 17.

Ensure that the Maven bits use the updated mechanisms to consume a WSDL and generate the SOAP Java types for a Spring WS client to talk to the server.
This commit is contained in:
Greg L. Turnquist
2023-08-01 16:42:20 -05:00
parent 6fa8b00b7d
commit b6b3773954
5 changed files with 31 additions and 68 deletions

View File

@@ -20,16 +20,11 @@ The service provides country data. You will be able to query data about a countr
== What You Need
:java_version: 1.8
:java_version: 17
include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/prereq_editor_jdk_buildtools.adoc[]
include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/how_to_complete_this_guide.adoc[]
NOTE: If you read link:/guides/gs/producing-web-service[Producing a SOAP web service], you
might wonder why this guide does not use `spring-boot-starter-ws`? That Spring Boot
starter is only for server-side web services. That starter brings on board such things as
embedded Tomcat, which is not needed to make a web call.
== Run the Target Web Service Locally
Follow the steps in the
@@ -79,15 +74,6 @@ include::complete/pom.xml[tags=dependency]
----
====
The following listing shows the profile you need to add in Maven if you want it to work with Java 11:
====
[source,xml,indent=0]
----
include::complete/pom.xml[tags=profile]
----
====
The <<initial>> section describes the WSDL generation plugin.
The following listing shows the final `pom.xml` file:

View File

@@ -5,9 +5,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<!-- lookup parent from repository -->
<relativePath/>
<version>3.1.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>consuming-web-service-complete</artifactId>
@@ -16,14 +15,10 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- tag::dependency[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -44,24 +39,6 @@
</dependency>
</dependencies>
<!-- tag::profile[] -->
<profiles>
<profile>
<id>java11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
<!-- end::profile[] -->
<build>
<plugins>
<plugin>
@@ -70,25 +47,25 @@
</plugin>
<!-- tag::wsdl[] -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.example.consumingwebservice.wsdl</generatePackage>
<schemas>
<schema>
<url>http://localhost:8080/ws/countries.wsdl</url>
</schema>
</schemas>
</configuration>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.example.consumingwebservice.wsdl</packageName>
<wsdlUrls>
<wsdlUrl>http://localhost:8080/ws/countries.wsdl</wsdlUrl>
</wsdlUrls>
<sourceDestDir>${sourcesDir}</sourceDestDir>
<destDir>${classesDir}</destDir>
<extension>true</extension>
</configuration>
</plugin>
<!-- end::wsdl[] -->
</plugins>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<version>3.1.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
@@ -15,15 +15,10 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@@ -0,0 +1,6 @@
logging:
level:
com.example.consumingwebservice: INFO
org:
springframework:
ws: DEBUG