Git Product home page Git Product logo

gs-consuming-web-service's Introduction

This guide walks you through the process of consuming a SOAP-based web service with Spring.

What You Will Build

You will build a client that fetches country data from a remote, WSDL-based web service by using SOAP. You can find out more about the country service and run the service yourself by following this guide.

The service provides country data. You will be able to query data about a country based on its name.

Run the Target Web Service Locally

Follow the steps in the companion guide or clone the repository and run the service (for example, by using mvn spring-boot:run) from its complete directory. You can verify that it works by visiting http://localhost:8080/ws/countries.wsdl in your browser. If you do not do so, you will see a confusing exception in your build later from the JAXB tooling.

Starting with Spring Initializr

For all Spring applications, you should start with the Spring Initializr. The Initializr offers a fast way to pull in all the dependencies you need for an application and does a lot of the setup for you. This example needs only the Spring Web Services dependency.

You can use this pre-initialized project and click Generate to download a ZIP file. This project is configured to fit the examples in this tutorial.

To initialize the project:

  1. Navigate to https://start.spring.io. This service pulls in all the dependencies you need for an application and does most of the setup for you.

  2. Choose either Gradle or Maven and the language you want to use. This guide assumes that you chose Java.

  3. Click Dependencies and select Spring Web Services.

  4. Click Generate.

  5. Download the resulting ZIP file, which is an archive of a web application that is configured with your choices.

Note
If your IDE has the Spring Initializr integration, you can complete this process from your IDE.
Note
You can also fork the project from Github and open it in your IDE or other editor.

Modify the Build Files

The build files created by the Spring Initializr need quite a bit of work for this guide. Also, the modifications to pom.xml (for Maven) and build.gradle (for Gradle) differ substantially.

Maven

For Maven, you need to add a dependency, a profile, and a WSDL generation plugin.

The following listing shows the dependency you need to add in Maven:

link:complete/pom.xml[role=include]

The Generate Domain Objects Based on a WSDL section describes the WSDL generation plugin.

The following listing shows the final pom.xml file:

link:complete/pom.xml[role=include]

Gradle

For Gradle, you need to add a dependency, a configuration, a bootJar section, and a WSDL generation plugin.

The following listing shows the dependency you need to add in Gradle:

link:complete/build.gradle[role=include]

Note the exclusion of Tomcat. If Tomcat is allowed to run in this build, you get a port collision with the Tomcat instance that provides the country data.

Note
Due to this port collision, the initial project fails to start. You can fix it by adding an application.properties file with a single property of server.port=8081. Since the initial project exists to be a starting point, you can skip trying to get it to run.

The Generate Domain Objects Based on a WSDL section describes the WSDL generation plugin.

The following listing shows the final build.gradle file:

link:complete/build.gradle[role=include]

Generate Domain Objects Based on a WSDL

The interface to a SOAP web service is captured in WSDL. JAXB provides a way to generate Java classes from WSDL (or rather, the XSD contained in the <Types/> section of the WSDL). You can find the WSDL for the country service at http://localhost:8080/ws/countries.wsdl.

To generate Java classes from the WSDL in Maven, you need the following plugin setup:

link:complete/pom.xml[role=include]

This setup generates classes for the WSDL found at the specified URL, putting those classes in the com.example.consumingwebservice.wsdl package. To generate that code run, ./mvnw compile and then look in target/generated-sources if you want to check that it worked.

To do the same with Gradle, you need the following in your build file:

link:complete/build.gradle[role=include]

As Gradle does not (yet) have a JAXB plugin, it involves an Ant task, which makes it a bit more complex than in Maven. To generate that code run ./gradlew compileJava and then look in build/generated-sources if you want to check that it worked.

In both Maven and Gradle, the JAXB domain object generation process has been wired into the build tool’s lifecycle, so you need not run any extra steps once you have a successful build.

Create a Country Service Client

To create a web service client, you have to extend the WebServiceGatewaySupport class and code your operations, as the following example (from src/main/java/com/example/consumingwebservice/CountryClient.java) shows:

link:complete/src/main/java/com/example/consumingwebservice/CountryClient.java[role=include]

The client contains one method (getCountry) that does the actual SOAP exchange.

In this method, both the GetCountryRequest and the GetCountryResponse classes are derived from the WSDL and were generated in the JAXB generation process (described in Generate Domain Objects Based on a WSDL). It creates the GetCountryRequest request object and sets it up with the country parameter (the name of the country). After printing out the country name, it uses the WebServiceTemplate supplied by the WebServiceGatewaySupport base class to do the actual SOAP exchange. It passes the GetCountryRequest request object (as well as a SoapActionCallback to pass on a SOAPAction header with the request) as the WSDL described that it needed this header in the <soap:operation/> elements. It casts the response into a GetCountryResponse object, which is then returned.

Configuring Web Service Components

Spring WS uses Spring Framework’s OXM module, which has the Jaxb2Marshaller to serialize and deserialize XML requests, as the following example (from src/main/java/com/example/consumingwebservice/CountryConfiguration.java) shows:

link:complete/src/main/java/com/example/consumingwebservice/CountryConfiguration.java[role=include]

The marshaller is pointed at the collection of generated domain objects and will use them to both serialize and deserialize between XML and POJOs.

The countryClient is created and configured with the URI of the country service shown earlier. It is also configured to use the JAXB marshaller.

Run the Application

This application is packaged up to run from the console and retrieve the data for a given country name, as the following listing (from src/main/java/com/example/consumingwebservice/ConsumingWebServiceApplication.java) shows:

link:complete/src/main/java/com/example/consumingwebservice/ConsumingWebServiceApplication.java[role=include]

The main() method defers to the SpringApplication helper class, providing CountryConfiguration.class as an argument to its run() method. This tells Spring to read the annotation metadata from CountryConfiguration and to manage it as a component in the Spring application context.

Note
This application is hard-coded to look up 'Spain'. Later in this guide, you will see how to enter a different symbol without editing the code.

Logging output is displayed. The service should be up and running within a few seconds.

The following listing shows the initial response:

Requesting country data for Spain

<getCountryRequest><name>Spain</name>...</getCountryRequest>

You can plug in a different country by running the following command:

java -jar build/libs/gs-consuming-web-service-0.1.0.jar Poland

Then the response changes to the following:

Requesting location for Poland

<getCountryRequest><name>Poland</name>...</getCountryRequest>

Summary

Congratulations! You have just developed a client to consume a SOAP-based web service with Spring.

gs-consuming-web-service's People

Contributors

atpollmann avatar buzzardo avatar gabrielsmenezes avatar gregturn avatar huangbowen521 avatar kcbaltz avatar krios2146 avatar ma501 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gs-consuming-web-service's Issues

Error creating bean with name 'messageConverters' while running the application

Hi,

so my previous attempt to solve this problem failed, thus I clonned the git repository, followed the guide and builded sources in the 'complete' directory with no error, but when I did:

 ~/Projects/gs-consuming-web-service/complete (master)
$ java -jar build/libs/complete.jar

..
..

2015-10-23 09:23:49.865  WARN 14104 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageConverters' defined in class path resource [org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.web.HttpMessageConverters]: Factory method 'messageConverters' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverter

Sample doesn't run under Java 11

This consumer example server doesn't run properly under Java 11, even though the build will pass the smoke test. When running it under gradle and maven the server doesn't last past boot and produces the following:

2020-01-08 16:47:14.406  INFO 8381 --- [           main] c.e.consumingwebservice.CountryClient    : Requesting location for Spain
2020-01-08 16:47:14.412 DEBUG 8381 --- [           main] o.s.ws.client.core.WebServiceTemplate    : Opening [org.springframework.ws.transport.http.HttpUrlConnection@cb0f763] to [http://localhost:8080/ws/countries]
2020-01-08 16:47:14.444 DEBUG 8381 --- [           main] o.s.ws.client.MessageTracing.sent        : Sent request [SaajSoapMessage {http://spring.io/guides/gs-producing-web-service}getCountryRequest]
2020-01-08 16:47:14.511 DEBUG 8381 --- [           main] o.s.ws.client.MessageTracing.received    : Received response [SaajSoapMessage {http://schemas.xmlsoap.org/soap/envelope/}Fault] for request [SaajSoapMessage {http://spring.io/guides/gs-producing-web-service}getCountryRequest]
2020-01-08 16:47:14.512 DEBUG 8381 --- [           main] o.s.ws.client.core.WebServiceTemplate    : Received Fault message for request [SaajSoapMessage {http://spring.io/guides/gs-producing-web-service}getCountryRequest]
2020-01-08 16:47:14.514  INFO 8381 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-01-08 16:47:14.518 ERROR 8381 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:787) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at com.example.consumingwebservice.ConsumingWebServiceApplication.main(ConsumingWebServiceApplication.java:15) ~[classes/:na]
Caused by: org.springframework.ws.soap.client.SoapFaultClientException: Implementation of JAXB-API has not been found on module path or classpath.
	at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:38) ~[spring-ws-core-3.0.7.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:830) ~[spring-ws-core-3.0.7.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:624) ~[spring-ws-core-3.0.7.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555) ~[spring-ws-core-3.0.7.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390) ~[spring-ws-core-3.0.7.RELEASE.jar:na]
	at com.example.consumingwebservice.CountryClient.getCountry(CountryClient.java:25) ~[classes/:na]
	at com.example.consumingwebservice.ConsumingWebServiceApplication.lambda$lookup$0(ConsumingWebServiceApplication.java:26) ~[classes/:na]
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	... 5 common frames omitted

I did also have the producer service running. Worked on trying to get around this for most of the day, and didn't make any headway. Java 11 is a requirement for my purposes.

Mixing weather and stock quotes

The text in the guide is talking about a weather app, when in the code is implementing a stock share app.
Can I fork it and fix it?
Thanks

Wrong class in the SpringApplication.run method

I hope I understood your guide correctly:

"The main() method defers to the SpringApplication helper class, providing WeatherConfiguration.class as an argument to its run() method."

and there should be:

public static void main(String[] args) {
SpringApplication.run(WeatherConfiguration.class);
}

instead of Application.class

JAXB-API error when running with gradle bootRun

I just tested with the example code from the repository with Zulu JDK 11.

In the complete directory build goes fine, but bootRun causes following error:

java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:774) ~[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:755) ~[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.1.jar:2.7.1] at com.example.consumingwebservice.ConsumingWebServiceApplication.main(ConsumingWebServiceApplication.java:15) ~[main/:na] Caused by: org.springframework.ws.soap.client.SoapFaultClientException: Implementation of JAXB-API has not been found on module path or classpath. at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:38) ~[spring-ws-core-3.1.3.jar:na] at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:795) ~[spring-ws-core-3.1.3.jar:na] at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:605) ~[spring-ws-core-3.1.3.jar:na] at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:542) ~[spring-ws-core-3.1.3.jar:na] at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:394) ~[spring-ws-core-3.1.3.jar:na] at com.example.consumingwebservice.CountryClient.getCountry(CountryClient.java:25) ~[main/:na] at com.example.consumingwebservice.ConsumingWebServiceApplication.lambda$lookup$0(ConsumingWebServiceApplication.java:26) ~[main/:na] at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:771) ~[spring-boot-2.7.1.jar:2.7.1] ... 5 common frames omitted

I tested both gradle bootRun and mvn spring-boot:run

WSDL returning no data

Hi, any chance of having the project updated soon or suggestions for alternate wsdl's than stock quote.
At the moment all it return is exception, so the example does not work well at the moment

Old parameter name in the CommandLineRunner

In the previous version of the guide, there was a QuoteClient, and the name of the parameter hasn't been changed.

Using quoteClient for a CountryClient may be confusing.

@Bean
CommandLineRunner lookup(CountryClient quoteClient) {
return args -> {
String country = "Spain";
if (args.length > 0) {
country = args[0];
}
GetCountryResponse response = quoteClient.getCountry(country);
System.err.println(response.getCountry().getCurrency());
};
}

pom.xml

I get the following error on line 44 in the pom.xml file:
"Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed: A required class was missing while executing."
screenshot_1

This makes it unable to generate the hello.wsdl file.

Missing arg-parameter in main method of Application

There is a bug in the main method of Application class
public static void main(String[] args) { SpringApplication.run(Application.class); }
should be
public static void main(String[] args) { SpringApplication.run(Application.class, args); }
Otherwise the command line arguments are not passed to the lookup method.

Gradle: Execute genJaxb task automatically on Eclipse/STS import and project refreshes

When these projects are imported in STS using gradle they initially have build path errors.

There's a task in the build script 'genJaxb' that can be run to provide the missing stuff.

Please consider automatically executing this task on project import (and refresh).
This can be accomplished by adding the following lines to the build.gradle:

    task afterEclipseImport {
        dependsOn genJaxb
    }

The afterEclipseImport task is a 'hook'. If the task is defined STS will execute it to finalize project setup after import. The task will also be re-executed when the user invokes 'Gradle >> Refresh All'.

Binding files, conflicts

Hey, is it possible to get an updated guide that also includes if property and element has the same name in a complextype ?

Basicly how to use binding files in this current setup.

Using own wsdl fails

I'm trying to change the WSDL to use my own, but no classes are generated 👎
It only makes the .episode and that is it.
I can generate all the classes and java files using wsimport, but I'm not sure combining wsimport and this project is a good idea.

Any idea why no classes/java are generated?
(I'm sure you need more info :-))
Thanks in advance

Update Spring Boot version

Update the guide to use the most recent Spring Boot version.

To do so, update the Spring Boot version in:

initial/build.gradle
initial/pom.xml
complete/build.gradle
complete/pom.xml

Doesn't generate hello package with maven

$ mvn clean compile

Just hang there and nothing was generated.

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-consuming-web-service 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-jaxb2-plugin:0.12.3:generate (default) @ gs-consuming-web-service ---
[INFO] Up-to-date check for source resources [[http://www.webservicex.com/stockquote.asmx?WSDL, file:/Users/huajieyang/github/gs-consuming-web-service/initial/pom.xml]] and taret resources [[]].
[WARNING] The URI [http://www.webservicex.com/stockquote.asmx?WSDL] seems to represent an absolute HTTP or HTTPS URL. Getting the last modification timestamp is only possible if the URL is accessible and if the server returns the [Last-Modified] header correctly. This method is not reliable and is likely to fail. In this case the last modification timestamp will be assumed to be unknown.

Does not build with jdk 11

Tried JDK 11 with the complete repository out of the box:

[WARNING] The POM for org.glassfish.jaxb:jaxb-runtime:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jaxb:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Error injecting: org.jvnet.mjiip.v_2.XJC2Mojo
java.lang.NoClassDefFoundError: com/sun/xml/bind/api/ErrorListener

Package wsdl doesn't exist

this imports are in WeatherClient but there's no package or something to locate:
import hello.wsdl.Forecast;
import hello.wsdl.ForecastReturn;
import hello.wsdl.GetCityForecastByZIP;
import hello.wsdl.GetCityForecastByZIPResponse;
import hello.wsdl.Temp;

maven-jaxb2-plugin not generaing all classes - requests and responses for WSDL

We have an example WSDL that has been provided by an API provider and we want to integrate with it.
I tried the provided example at https://spring.io/guides/gs/consuming-web-service/ and some other .wsdl files and it all looks good.
In my case with my wsdl - when running the command to generate the classes - only some of them are generated, but not all of them.
This is not the case in SoapUI - all is good there.
Any info why this is happening?

My pom.xml is the following

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <generatePackage>com.test.xxx.soapclient.generated</generatePackage>
                    <generateDirectory>${project.basedir}/src/main/java</generateDirectory>
                    <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
                    <schemaIncludes>
                        <include>*.wsdl</include>
                    </schemaIncludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

What i have come to see is that only the complex types are being created as classes - while the others are not.
In my example the input message is the one below and no classes are being generated for it.
How can i do that?
Also what is interesting here is - soapAction has empty string as parameter - and Java's API requires SoapAction
Java Code

 public Object callWebService(String action, Object request){
        return getWebServiceTemplate().marshalSendAndReceive(request,new SoapActionCallback(action));
    }

Actual WSDL File

<operation name="login" parameterOrder="user password">
  <input message="tns:CardManagementEP_login"> </input>
  <output message="tns:CardManagementEP_loginResponse"> </output>
</operation>

<message name="CardManagementEP_loginResponse">
<part name="result" type="xsd:string"> </part>
</message>

<message name="CardManagementEP_login">
<part name="user" type="xsd:string"> </part>
<part name="password" type="xsd:string"> </part>
</message>

<operation name="login">
  <soap:operation soapAction=""/>
  <input>
  <soap:body use="literal" namespace="http://com.tch.cards.service"/>
  </input>
  <output>
  <soap:body use="literal" namespace="http://com.tch.cards.service"/>
  </output>
</operation>

Sample built with Gradle doesn't run with "java -jar" on Java 11

Hello

My JDK

openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.17.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20191016_371 (JIT enabled, AOT enabled)
OpenJ9   - 77c1cf708
OMR      - 20db4fbc
JCL      - 2a7af5674b based on jdk-11.0.5+10)

Exception

java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:787) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
        at com.example.consumingwebservice.ConsumingWebServiceApplication.main(ConsumingWebServiceApplication.java:15) ~[classes!/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[gs-consuming-web-service-0.0.1.jar:na]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[gs-consuming-web-service-0.0.1.jar:na]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) ~[gs-consuming-web-service-0.0.1.jar:na]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) ~[gs-consuming-web-service-0.0.1.jar:na]
Caused by: org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: class com.example.consumingwebservice.wsdl.GetCountryRequest nor any of its super class is known to this context.
        at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:955) ~[spring-oxm-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
        at org.springframework.oxm.jaxb.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:713) ~[spring-oxm-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
        at org.springframework.ws.support.MarshallingUtils.marshal(MarshallingUtils.java:81) ~[spring-ws-core-3.0.7.RELEASE.jar!/:na]
        at org.springframework.ws.client.core.WebServiceTemplate$2.doWithMessage(WebServiceTemplate.java:399) ~[spring-ws-core-3.0.7.RELEASE.jar!/:na]
        at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:590) ~[spring-ws-core-3.0.7.RELEASE.jar!/:na]
        at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555) ~[spring-ws-core-3.0.7.RELEASE.jar!/:na]
        at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390) ~[spring-ws-core-3.0.7.RELEASE.jar!/:na]
        at com.example.consumingwebservice.CountryClient.getCountry(CountryClient.java:25) ~[classes!/:na]
        at com.example.consumingwebservice.ConsumingWebServiceApplication.lambda$lookup$0(ConsumingWebServiceApplication.java:26) ~[classes!/:na]
        at com.example.consumingwebservice.ConsumingWebServiceApplication$$Lambda$287.0000000000000000.run(Unknown Source) ~[na:na]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
        ... 13 common frames omitted
Caused by: javax.xml.bind.JAXBException: class com.example.consumingwebservice.wsdl.GetCountryRequest nor any of its super class is known to this context.
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:563) ~[jaxb-runtime-2.3.2.jar!/:2.3.2]
        at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:452) ~[jaxb-runtime-2.3.2.jar!/:2.3.2]
        at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:298) ~[jaxb-runtime-2.3.2.jar!/:2.3.2]
        at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:226) ~[jaxb-runtime-2.3.2.jar!/:2.3.2]
        at org.springframework.oxm.jaxb.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:709) ~[spring-oxm-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
        ... 22 common frames omitted

Unknown jaxb exception

I checked this dependency for java 21, it doesn't work, it works with java 17, but has anyone tested it for java 21?

`plugins {
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
id 'java'
id "org.owasp.dependencycheck" version "6.1.2"
}

dependencies {
implementation('org.springframework.boot:spring-boot-starter-web-services') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
implementation "com.sun.xml.ws:jaxws-tools:3.0.0"
implementation "jakarta.xml.ws:jakarta.xml.ws-api:3.0.0"
implementation "jakarta.activation:jakarta.activation-api:2.0.0"
implementation "com.sun.xml.ws:jaxws-rt:3.0.0"

implementation "jakarta.xml.bind:jakarta.xml.bind-api:3.0.0"
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
}`

java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory

Trying to use the example in a existing spring project (spring 3.x) getting

* What went wrong:
Execution failed for task ':genJaxb'.
> java.lang.AssertionError: jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
   - with linked exception:
  [java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]

Build failure with JDK 1.8.0_91-b14

Following the tutorial on my machine (STS, JDK 1.8.0_91-b14, windows) fails with :

[INFO] --- maven-jaxb2-plugin:0.12.3:generate (default) @ gs-consuming-web-service ---
[WARNING] The POM for org.glassfish.jaxb:jaxb-runtime:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jaxb:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Error injecting: org.jvnet.mjiip.v_2.XJC2Mojo
java.lang.NoClassDefFoundError: com/sun/xml/bind/api/ErrorListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
(... snip ...)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.api.ErrorListener
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)

Upgrading the maven-jaxb2-plugin to latest version and adding jaxb dependencies fixes the issue :

    <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>hello.wsdl</generatePackage>
                    <schemas>
                        <schema>
                            <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                        </schema>
                    </schemas>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>2.2.11</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-xjc</artifactId>
                        <version>2.2.11</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-core</artifactId>
                        <version>2.2.11</version>
                    </dependency>
                </dependencies>
            </plugin>

Incorrect step (Make the application executable) in the guide

  1. The step says CountryConfiguration.class is passed as an argument to the run() method
    but the code is passing Application.class as argument to the run method.

  2. lookup method parameter type is CountryClient but the parameter is named as quoteClient

  3. The paragraph "This application is hard coded to look up symbol 'MSFT' which correspond to Microsoft Corporation. Towards the end of this guide, you’ll see how to plug in a different symbol without editing the code." does not belong to this guide.

Documentation links

The links to code examples are not displayed correctly in the Readme and the original article (https://spring.io/guides/gs/consuming-web-service/#scratch). For example:

The following listing shows the pom.xml file that is created when you choose Maven:

link:initial/pom.xml[]
The following listing shows the build.gradle file that is created when you choose Gradle:

link:initial/build.gradle[]

Maven doesn't work or it's my problem with proxy?!

As far as I can see, my proxy configuration is correct, in the settings: other Maven-based projects (also from Spring Guides) work properly. For this guide, Gradle works and download but Maven doesn't.

This is the stacktrace:

C:\Users\mbresciani\Desktop\Spring\Guides\Consuming a SOAP web service>"c:\Progr
am Files\apache-maven-3.2.2\bin\mvn.bat" -e compile
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
org.springframework:gs-consuming-web-service:jar:0.1.0
[WARNING] 'build.plugins.plugin.version' for org.jvnet.jaxb2.maven2:maven-jaxb2-
plugin is missing. @ line 44, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
g such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-consuming-web-service 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-jaxb2-plugin:0.9.0:generate (default) @ gs-consuming-web-servic
e ---
[INFO] Sources are not up-to-date; XJC execution will be executed.
[ERROR] Error while parsing schema(s).Location [].
java.net.ConnectException: Connection refused: connect
        at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:94)
        at com.sun.tools.xjc.reader.internalizer.DOMForest.parse(DOMForest.java:
413)
        at com.sun.tools.xjc.reader.internalizer.DOMForest.parse(DOMForest.java:
285)
        at com.sun.tools.xjc.ModelLoader.buildDOMForest(ModelLoader.java:324)
        at com.sun.tools.xjc.ModelLoader.loadWSDL(ModelLoader.java:391)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:170)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:50)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:318)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:161)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThre
adedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:323)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC
onnection.java:860)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:801)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:726)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1049)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrent
Entity(XMLEntityManager.java:677)
        at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineD
ocVersion(XMLVersionDetector.java:186)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:772)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.
java:119)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab
stractSAXParser.java:1205)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p
arse(SAXParserImpl.java:522)
        at com.sun.tools.xjc.reader.internalizer.DOMForest.parse(DOMForest.java:
405)
        ... 31 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.109 s
[INFO] Finished at: 2014-08-28T12:41:55+02:00
[INFO] Final Memory: 8M/77M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.9.0:g
enerate (default) on project gs-consuming-web-service: Execution default of goal
 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.9.0:generate failed. NullPointerExc
eption -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.9.0:generate (default) on project gs-
consuming-web-service: Execution default of goal org.jvnet.jaxb2.maven2:maven-ja
xb2-plugin:0.9.0:generate failed.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:224)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThre
adedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default o
f goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.9.0:generate failed.
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:143)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:208)
        ... 19 more
Caused by: java.lang.NullPointerException
        at com.sun.tools.xjc.ModelLoader.loadWSDL(ModelLoader.java:408)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:170)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:50)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:318)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:161)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:132)
        ... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutio
nException

And here below the Maven (I had it from the downloaded 'initial' file):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>gs-consuming-web-service</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.5.RELEASE</version>
    </parent>

    <properties>
        <!-- use UTF-8 for everything -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- tag::wsdl[] -->
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>hello.wsdl</generatePackage>
                    <forceRegenerate>true</forceRegenerate>
                    <schemas>
                        <schema>
                            <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                        </schema>
                    </schemas>
                </configuration>
            </plugin>
            <!-- end::wsdl[] -->
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>http://repo.spring.io/libs-release</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>http://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>

</project>

Doesn't print the expected result

The method printResponse on the class WeatherClient is never called and so it never prints nothing, looking on older versions I found that the call was erased from the Main and putting it on the CommandLineRunner after the response is created works

Add a note that the example does not work through proxy (unless, probably, specifically configured)

This is the error I see when running the example (with Gradle) being in a proxied intranet:

C:\Users\mbresciani\Desktop\Spring\Guides\Consuming a SOAP web service>"c:\Progr
am Files (x86)\gradle-2.0\bin\gradle.bat" bootRun --stacktrace
:genJaxb UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:bootRun

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.5.RELEASE)

2014-08-28 13:19:02.050  INFO 4676 --- [           main] hello.Application
                  : Starting Application on L-IT-05839 with PID 4676 (started by
 MBresciani in C:\Users\mbresciani\Desktop\Spring\Guides\Consuming a SOAP web se
rvice)
2014-08-28 13:19:02.079  INFO 4676 --- [           main] s.c.a.AnnotationConfigA
pplicationContext : Refreshing org.springframework.context.annotation.Annotation
ConfigApplicationContext@11e7c5cb: startup date [Thu Aug 28 13:19:02 CEST 2014];
 root of context hierarchy
2014-08-28 13:19:02.236  INFO 4676 --- [           main] o.s.oxm.jaxb.Jaxb2Marsh
aller             : Creating JAXBContext with context path [hello.wsdl]
2014-08-28 13:19:02.344  INFO 4676 --- [           main] o.s.ws.soap.saaj.SaajSo
apMessageFactory  : Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
2014-08-28 13:19:02.358  INFO 4676 --- [           main] hello.Application
                  : Started Application in 0.745 seconds (JVM running for 0.981)


Requesting forecast for 94304
Exception in thread "main" org.springframework.ws.client.WebServiceIOException:
I/O error: Connection refused: connect; nested exception is java.net.ConnectExce
ption: Connection refused: connect
        at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(
WebServiceTemplate.java:561)
        at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndR
eceive(WebServiceTemplate.java:390)
        at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndR
eceive(WebServiceTemplate.java:383)
        at hello.WeatherClient.getCityForecastByZip(WeatherClient.java:23)
        at hello.Application.main(Application.java:19)
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:323)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC
onnection.java:860)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:801)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:726)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLCo
nnection.java:904)
        at org.springframework.ws.transport.http.HttpUrlConnection.getRequestOut
putStream(HttpUrlConnection.java:85)
        at org.springframework.ws.transport.AbstractSenderConnection$RequestTran
sportOutputStream.createOutputStream(AbstractSenderConnection.java:106)
        at org.springframework.ws.transport.TransportOutputStream.getOutputStrea
m(TransportOutputStream.java:41)
        at org.springframework.ws.transport.TransportOutputStream.write(Transpor
tOutputStream.java:64)
2014-08-28 13:19:04.471  INFO 4676 --- [       Thread-1] s.c.a.AnnotationConfigA
pplicationContext : Closing org.springframework.context.annotation.AnnotationCon
figApplicationContext@11e7c5cb: startup date [Thu Aug 28 13:19:02 CEST 2014]; ro
ot of context hierarchy
        at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageI
mpl.java:1217)
        at org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMess
age.java:275)
        at org.springframework.ws.transport.AbstractWebServiceConnection.send(Ab
stractWebServiceConnection.java:46)
        at org.springframework.ws.client.core.WebServiceTemplate.sendRequest(Web
ServiceTemplate.java:654)
        at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceiv
e(WebServiceTemplate.java:603)
        at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(
WebServiceTemplate.java:555)
        ... 4 more
:bootRun FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command 'C:\Program Files\Java\jdk1.6.0_21\bin\java.exe'' finished wi
th non-zero exit value 1

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bootRun
'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExec
uter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
ute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
e(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
ter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
e(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailur
e(AbstractTask.java:296)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.executeTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.processTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.run(AbstractTaskPlanExecutor.java:51)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(Defaul
tTaskPlanExecutor.java:23)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(Defau
ltTaskGraphExecuter.java:86)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTask
ExecutionAction.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:61)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExec
uter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecu
ter.java:67)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildEx
ecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:61)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:54)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:148)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:105)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:85)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:81)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:39)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:29)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.jav
a:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Progr
am Files\Java\jdk1.6.0_21\bin\java.exe'' finished with non-zero exit value 1
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNo
rmalExitValue(DefaultExecHandle.java:365)
        at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJava
ExecAction.java:31)
        at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:60)
        at org.springframework.boot.gradle.run.BootRunTask.exec(BootRunTask.java
:56)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
ctTask.java:570)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
ctTask.java:553)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
        ... 44 more


BUILD FAILED

Total time: 8.364 secs

Multiple SOAP operations in same wsdl

Hi - I have been provided a WSDL file which has multiple operations. I tried your example and it works good if WSDL contain only one operation but not sure how can I adopt this when I need to call different SOAP methods/end points for different actions.

Appreciate any feedback.

It's not working

The web service url may not be correct and when I clone and run the java -jar target/xxx.jar it will git the timeout exception. can we double check the weather soap web service url is correct?

exception messages are similar like following:
2015-08-11 14:20:19.478 INFO 10332 --- [ main] hello.Application : Started Application in 0.899 seconds (JVM running for 1.424)

Requesting forecast for 94304
Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: Server was unable to process request. ---> Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

JAXB-API cannot be found even if I added the dependency in pom.xml

I use JDK 1.8 to test the example codes with IDEA 2020, but JAXB-API cannot be found even if I added the dependecies in pom.xml. The detailed error information is as following:

2020-05-03 12:23:36.951 ERROR 11992 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:787) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
	at com.example.demo2.Demo2Application.main(Demo2Application.java:14) [classes/:na]
**Caused by: org.springframework.ws.soap.client.SoapFaultClientException: Implementation of JAXB-API has not been found on module path or classpath.**
	at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:38) ~[spring-ws-core-3.0.8.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:830) ~[spring-ws-core-3.0.8.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:624) ~[spring-ws-core-3.0.8.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555) ~[spring-ws-core-3.0.8.RELEASE.jar:na]
	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390) ~[spring-ws-core-3.0.8.RELEASE.jar:na]
	at com.example.demo2.CountryClient.getCountry(CountryClient.java:24) ~[classes/:na]
	at com.example.demo2.Demo2Application.lambda$lookup$0(Demo2Application.java:25) [classes/:na]
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
	... 5 common frames omitted

Could you please help me, thank you!

NullPointerException when trying to compile with Gradle

I just cloned the project today and pulled out the "complete" directory. When I ran ./gradlew compileJava, I get a NullPointerException, as can be seen in the Gradle stack trace below. How can I fix this?

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':genJaxb'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101) at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46) at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) Caused by: : java.lang.NullPointerException at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116) at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:78) at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:103) at org.gradle.internal.metaobject.BeanDynamicObject$GroovyObjectAdapter.invokeOpaqueMethod(BeanDynamicObject.java:579) at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:506) at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:191) at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:57) at build_2gu5zicgatck7prqjxc26xb5h$_run_closure3$_closure7$_closure8.doCall(C:\Users\spart\IdeaProjects\gs-consuming-web-service\complete\build.gradle:36) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71) at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:155) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106) at org.gradle.api.internal.project.DefaultProject.ant(DefaultProject.java:1132) at org.gradle.api.Project$ant.call(Unknown Source) at build_2gu5zicgatck7prqjxc26xb5h$_run_closure3$_closure7.doCall(C:\Users\spart\IdeaProjects\gs-consuming-web-service\complete\build.gradle:30) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:739) at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:712) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99) ... 31 more Caused by: java.lang.NullPointerException at com.sun.tools.xjc.ModelLoader.loadWSDL(ModelLoader.java:398) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:163) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113) at com.sun.tools.xjc.XJC2Task._doXJC(XJC2Task.java:487) at com.sun.tools.xjc.XJC2Task.doXJC(XJC2Task.java:434) at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:369) at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:55) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) ... 60 more

XML Exception with Java-WS

this is the code for java webservices and keep get the same error with soapUI and the same error for the xml, I'm working with jdk 8

I have issue with the endpoint of the java web services as it's show in the code but it's keep giving me this response as bellow:

Error loading[http://localhost:8096/ws/biller_customer_authentication]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Premature end of file

@EnableWs
@Configuration
public class WSConfig extends WsConfigurerAdapter {

    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/ws/*");
    }

    @Bean(name = "biller_customer_authentication")
    public DefaultWsdl11Definition billerCustomerAuthentication(XsdSchema billerCustomerAuthenticationSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("BillerCustomerAuthenticationPort");
        wsdl11Definition.setLocationUri("/ws");
        wsdl11Definition.setTargetNamespace("http://localhost:8096");
        wsdl11Definition.setSchema(billerCustomerAuthenticationSchema );
        return wsdl11Definition;
    }

    @Bean
    public XsdSchema billerCustomerAuthenticationSchema() {
        return new SimpleXsdSchema(new ClassPathResource("xsd/biller.xsd"));
    }
}

Migrate to Java 11

I am trying to use this example to generate jaxb classes for Java 11. I changed source and target in javac command in build.gradle to "1.11" from 1.8. But I am getting an error: java.lang.Error: java.lang.reflect.InvocationTargetException

Can someone tell me what changes I need to make ?

Updated examples and guides from Spring Framework 6 and jakarta classes?

Hi,

wondering if there is already work being done on updating creating and consuming SOAP services with new versions of the Spring Framework 6 and Spring Boot 3?

At the moment current example projects naturally fail if tried under 3.0.0 releases, as dependencies have been updated to jakarta 9+ classes.

Error occur when execute example with mvn: Unable to start embedded container;

I've cloned this repository and successfully run mvn clean package but when I tried to execute mvn spring-boot:run below exception occurred.

2014-07-03 12:44:42.478 ERROR 70959 --- [ main] o.s.boot.SpringApplication : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:683)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:944)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:933)
at hello.Application.main(Application.java:12)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
... 7 common frames omitted

Issues consuming-web-service on cloudfoundry

I followed your example to send and receive messages, my application works perfectly on local machine (localhost:8080) , but when I upload the application on cloudfoundry I get null pointer exception when i try to access response object.
please see attached logs log.txt

Have you test it on cloudfoundry ?

Question about authentication.

Hi,
I followed your tutorial and completed it successfully.
However, now I need to consume a soap web service that requires a pfx certificate as client authenticate. Do you know how can I set the certificate for the maven plugin to generate the classes?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.