Giter VIP home page Giter VIP logo

gs-producing-web-service's Introduction

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

What You Will build

You will build a server that exposes data from various European countries by using a WSDL-based SOAP web service.

Note
To simplify the example, you will use hardcoded data for the United Kingdom, Spain, and Poland.

Starting with Spring Initializr

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 manually 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 and 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
Both the pom.xml and build.gradle files need additional build information, which you will add in the next step.
Note
You can also fork the project from Github and open it in your IDE or other editor.

Add the Spring-WS dependency

The project needs to include spring-ws-core and wsdl4j as dependencies in your build file.

The following example shows the changes you need to make to the pom.xml file if you use Maven:

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

The following example shows the changes you need to make to the build.gradle file if you use Gradle:

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

Create an XML Schema to Define the Domain

The web service domain is defined in an XML schema file (XSD) that Spring-WS will automatically export as a WSDL.

Create an XSD file with operations to return a country’s name, population, capital, and currency. The following listing (from src/main/resources/countries.xsd) shows the necessary XSD file:

link:complete/src/main/resources/countries.xsd[role=include]

Generate Domain Classes Based on an XML Schema

The next step is to generate Java classes from the XSD file. The right approach is to do this automatically during build time by using a Maven or Gradle plugin.

The following listing shows the necessary plugin configuration for Maven:

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

Generated classes are placed in the target/generated-sources/jaxb/ directory.

To do the same with Gradle, you first need to configure JAXB in your build file, as the following listing shows:

link:complete/build.gradle[role=include]
Note
The build files have tag and end comments. These tags make it easier to extract bits of it into this guide for a more detailed explanation. You do not need these comments in your own build file.

The next step is to add the genJaxb task, which Gradle uses to generate Java classes. We need to configure gradle to find these generated Java classes in build/generated-sources/jaxb and add genJaxb as a dependency of compileJava task. The following listing shows the necessary addition:

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

Because Gradle does not have a JAXB plugin (yet), it involves an Ant task, which makes it a bit more complex than in Maven.

In both cases, the JAXB domain object generation process has been wired into the build tool’s lifecycle, so there are no extra steps to run.

Create Country Repository

In order to provide data to the web service, create a country repository. In this guide, you create a dummy country repository implementation with hardcoded data. The following listing (from src/main/java/com/example/producingwebservice/CountryRepository.java) shows how to do so:

link:complete/src/main/java/com/example/producingwebservice/CountryRepository.java[role=include]

Create Country Service Endpoint

To create a service endpoint, you need only a POJO with a few Spring WS annotations to handle the incoming SOAP requests. The following listing (from src/main/java/com/example/producingwebservice/CountryEndpoint.java) shows such a class:

link:complete/src/main/java/com/example/producingwebservice/CountryEndpoint.java[role=include]

The @Endpoint annotation registers the class with Spring WS as a potential candidate for processing incoming SOAP messages.

The @PayloadRoot annotation is then used by Spring WS to pick the handler method, based on the message’s namespace and localPart.

The @RequestPayload annotation indicates that the incoming message will be mapped to the method’s request parameter.

The @ResponsePayload annotation makes Spring WS map the returned value to the response payload.

Note
In all of these chunks of code, the io.spring.guides classes will report compile-time errors in your IDE unless you have run the task to generate the domain classes based on the WSDL.

Configure Web Service Beans

Create a new class with Spring WS-related beans configuration, as the following listing (from src/main/java/com/example/producingwebservice/WebServiceConfig.java) shows:

link:complete/src/main/java/com/example/producingwebservice/WebServiceConfig.java[role=include]
Important
You need to specify bean names for MessageDispatcherServlet and DefaultWsdl11Definition. Bean names determine the URL under which the web service and the generated WSDL file are available. In this case, the WSDL will be available under http://<host>:<port>/ws/countries.wsdl.

This configuration also uses the WSDL location servlet transformation: servlet.setTransformWsdlLocations(true). If you visit http://localhost:8080/ws/countries.wsdl, the soap:address will have the proper address. If you instead visit the WSDL from the public facing IP address assigned to your machine, you will see that address instead.

Make the Application Executable

Spring Boot creates an application class for you. In this case, it needs no further modification. You can use it to run this application. The following listing (from src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java) shows the application class:

link:complete/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java[role=include]

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

Test the Application

Now that the application is running, you can test it. Create a file called request.xml that contains the following SOAP request:

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

The are a few options when it comes to testing the SOAP interface. You can use something similar to SoapUI or use command-line tools if you are on a *nix/Mac system. The following example uses curl from the command line:

# Use data from file
curl --header "content-type: text/xml" -d @request.xml http://localhost:8080/ws
# Use inline XML data
curl <<-EOF -fsSL -H "content-type: text/xml" -d @- http://localhost:8080/ws \
  > target/response.xml && xmllint --format target/response.xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                  xmlns:gs="http://spring.io/guides/gs-producing-web-service">
   <soapenv:Header/>
   <soapenv:Body>
      <gs:getCountryRequest>
         <gs:name>Spain</gs:name>
      </gs:getCountryRequest>
   </soapenv:Body>
</soapenv:Envelope>

EOF

As a result, you should see the following response:

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <ns2:getCountryResponse xmlns:ns2="http://spring.io/guides/gs-producing-web-service">
      <ns2:country>
        <ns2:name>Spain</ns2:name>
        <ns2:population>46704314</ns2:population>
        <ns2:capital>Madrid</ns2:capital>
        <ns2:currency>EUR</ns2:currency>
      </ns2:country>
    </ns2:getCountryResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Note
Odds are that the output will be a compact XML document instead of the nicely formatted one shown above. If you have xmllib2 installed on your system, you can curl -fsSL --header "content-type: text/xml" -d @request.xml http://localhost:8080/ws > output.xml and xmllint --format output.xml see the results formatted nicely.

Summary

Congratulations! You have developed a SOAP-based service with Spring Web Services.

gs-producing-web-service's People

Contributors

buzzardo avatar elifarley avatar gregturn avatar huima avatar ifalko avatar kdvolder avatar maastiff avatar maciejwalkowiak avatar mdkhwajams avatar robertmcnees avatar royclarkson avatar sdeleuze avatar stevengeens 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

gs-producing-web-service's Issues

Describe that an explicit XSD file location is required in maven to generate source files

Excellent Guide. I just had one issue using Java 13 & maven 3.6.2. When editing the pom.xml I had to specify countries.xsd otherwise I was not able to generate the source files.
CURRENT DOC

<configuration>
		<sources>
			<source>${project.basedir}/src/main/resources/</source>
		</sources>
	</configuration>

ABLE TO GENERATE SOURCE BY SPECIFYING THE XSD FILE

<configuration>
		<sources>
			<source>${project.basedir}/src/main/resources/countries.xsd</source>
		</sources>
	</configuration>

Bean of type xxx is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

Runing this guide I saw the folowing messages in my log:
2022-11-17 12:57:15.938 INFO 14972 --- [ main] c.e.p.ProducingWebServiceApplication : Starting ProducingWebServiceApplication using Java 14.0.2 on DESKTOP-DMP4T2D with PID 14972 (D:\Work\SVN\spring-guides\gs-producing-wed-service\trunk\complete\target\classes started by s.romanov in D:\Work\SVN\spring-guides\gs-producing-wed-service\trunk)
2022-11-17 12:57:15.946 INFO 14972 --- [ main] c.e.p.ProducingWebServiceApplication : No active profile set, falling back to 1 default profile: "default"
2022-11-17 12:57:16.990 INFO 14972 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'webServiceConfig' of type [com.example.producingwebservice.WebServiceConfig$$EnhancerBySpringCGLIB$$85e86c46] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-11-17 12:57:16.990 INFO 14972 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config

How can I exclude this info messages from log: "Bean of type xxx is not eligible for ..."
I am runing maven version of the project
No problems with functionality. Soap service return response for request.

Not an issue, but a question :)

Hi, I have followed your tutorial and created an app (many thanks). However, now I want to use my .xsd file and with this namespace it will not work (404). How can I create my own namespace and use my own 'localPart' for PayloadRoot?
Thank you in advance! :)

Outdated Gradle JAXB related information

Hi.

While reading the official "Getting Started Guide: Producing a SOAP web service" I have noticed that it says (quote)

"As gradle does not have a JAXB plugin (yet), it involves an ant task, which makes it a bit more complex than in maven."

Actually that is not true. There are several Gradle JAXB plugins available so the "Generate domain classes based on an XML schema" section that covers Gradle related configuration can be much simpler if one the available plugins was used instead of writing JAXB task from ground up.

Anyway the "Getting Started Guide" could at least refer to the list of available Gradle JAXB plugins or mention the fact of their existence.

Multiple countries?

Is it possible to return a list of all countries in the CountryRepository class instead of just 1 country?

Example:

<ns2:getCountryResponse xmlns:ns2="http://spring.io/guides/gs-producing-web-service">
  <ns2:country>
    <ns2:name>Spain</ns2:name>
    <ns2:population>46704314</ns2:population>
    <ns2:capital>Madrid</ns2:capital>
    <ns2:currency>EUR</ns2:currency>
  </ns2:country>
  <ns2:country>
    <ns2:name>France</ns2:name>
    <ns2:population>123</ns2:population>
    <ns2:capital>Paris</ns2:capital>
    <ns2:currency>EUR</ns2:currency>
  </ns2:country>
  <ns2:country>
    <ns2:name>Germany</ns2:name>
    <ns2:population>456</ns2:population>
    <ns2:capital>Berlin</ns2:capital>
    <ns2:currency>EUR</ns2:currency>
  </ns2:country>
</ns2:getCountryResponse>

Problem with JDK10 to generate the sources on windows 10

Hello,

I cannot generate the sources with JDK10 on windows 10, running both gradlew and mvnw from the git for windows bash CLI:

Bernard@DESKTOP MINGW64 .../gs-producing-web-service/complete (master)
$ java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

Bernard@DESKTOP MINGW64 .../gs-producing-web-service/complete (master)
$ ./gradlew --stacktrace build
:genJaxbErrors occurred while build effective model from C:\Users\BernardPaulus\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\jaxb-xjc\2.2.11\2356f739b56bed93101e181ea67224f3ea35dc67\jaxb-xjc-2.2.11.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in org.glassfish.jaxb:jaxb-xjc:2.2.11
Errors occurred while build effective model from C:\Users\BernardPaulus\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\jaxb-core\2.2.11\f3208abdc61be827cf28838c3881213648807821\jaxb-core-2.2.11.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in org.glassfish.jaxb:jaxb-core:2.2.11
Errors occurred while build effective model from C:\Users\BernardPaulus\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\txw2\2.2.11\4be03527dbf2428f7ea99fb9c2f50f089dffad5e\txw2-2.2.11.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in org.glassfish.jaxb:txw2:2.2.11
Errors occurred while build effective model from C:\Users\BernardPaulus\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\codemodel\2.2.11\328b52a88fcab47e646af9f54580f95326557590\codemodel-2.2.11.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in org.glassfish.jaxb:codemodel:2.2.11
Errors occurred while build effective model from C:\Users\BernardPaulus\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind.external\rngom\2.2.11\ffb74f1c310b0694012b56319f39c4a31ed0148b\rngom-2.2.11.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind.external:rngom:2.2.11
Errors occurred while build effective model from C:\Users\BernardPaulus\.gradle\caches\modules-2\files-2.1\com.sun.istack\istack-commons-tools\2.21\25ebe0fb8451bb4cb700312c62ee3fc1be2131d8\istack-commons-tools-2.21.pom:
    'dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.istack:istack-commons-tools:2.21
 FAILED

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\BernardPaulus\OneDrive - Ferrologic AB\junk\java\spring\spring-ws-soap\gs-producing-web-service\complete\build.gradle' line: 35

* What went wrong:
Execution failed for task ':genJaxb'.
> java.lang.Error: java.lang.reflect.InvocationTargetException

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':genJaxb'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
        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.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        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.Error: java.lang.reflect.InvocationTargetException
        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_djs527exe8jd2i11g0xd0dimg$_run_closure2$_closure7$_closure8.doCall(C:\Users\BernardPaulus\OneDrive - Ferrologic AB\junk\java\spring\spring-ws-soap\gs-producing-web-service\complete\build.gradle:35)
        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:160)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
        at org.gradle.api.internal.project.DefaultProject.ant(DefaultProject.java:1107)
        at org.gradle.api.Project$ant.call(Unknown Source)
        at build_djs527exe8jd2i11g0xd0dimg$_run_closure2$_closure7.doCall(C:\Users\BernardPaulus\OneDrive - Ferrologic AB\junk\java\spring\spring-ws-soap\gs-producing-web-service\complete\build.gradle:29)
        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:726)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:699)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
        ... 30 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:147)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:117)
        at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:425)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:170)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at com.sun.tools.xjc.XJC2Task._doXJC(XJC2Task.java:517)
        at com.sun.tools.xjc.XJC2Task.doXJC(XJC2Task.java:457)
        at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:380)
        at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:103)
        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)
        ... 58 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
        ... 72 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
        at com.sun.tools.xjc.reader.xmlschema.BindingComponent.getClassSelector(BindingComponent.java:65)
        at com.sun.tools.xjc.reader.xmlschema.ColorBinder.<init>(ColorBinder.java:62)
        at com.sun.tools.xjc.reader.xmlschema.BindGreen.<init>(BindGreen.java:63)
        ... 76 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
        ... 79 more
Caused by: java.lang.NoClassDefFoundError: javax/activation/MimeTypeParseException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:100)
        at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.<init>(DefaultClassBinder.java:98)
        at com.sun.tools.xjc.reader.xmlschema.ClassSelector.<init>(ClassSelector.java:214)
        ... 83 more
Caused by: java.lang.ClassNotFoundException: javax.activation.MimeTypeParseException
        at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1386)
        at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1335)
        at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1090)
        ... 86 more


* Get more help at https://help.gradle.org

BUILD FAILED in 2s
1 actionable task: 1 executed
Bernard@DESKTOP MINGW64 .../gs-producing-web-service/complete (master)
$ ./mvnw package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-producing-web-service 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jaxb2-maven-plugin:1.6:xjc (xjc) @ gs-producing-web-service ---
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.592 s
[INFO] Finished at: 2018-06-21T11:00:12+02:00
[INFO] Final Memory: 19M/77M
[INFO] ------------------------------------------------------------------------
---------------------------------------------------
constituent[0]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/aether-api-1.0.2.v20150114.jar
constituent[1]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/aether-connector-basic-1.0.2.v20150114.jar
constituent[2]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/aether-impl-1.0.2.v20150114.jar
constituent[3]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/aether-spi-1.0.2.v20150114.jar
constituent[4]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/aether-transport-wagon-1.0.2.v20150114.jar
constituent[5]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/aether-util-1.0.2.v20150114.jar
constituent[6]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/aopalliance-1.0.jar
constituent[7]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/cdi-api-1.0.jar
constituent[8]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/commons-cli-1.2.jar
constituent[9]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/commons-io-2.2.jar
constituent[10]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/commons-lang-2.6.jar
constituent[11]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/commons-lang3-3.4.jar
constituent[12]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/guava-18.0.jar
constituent[13]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/guice-4.0-no_aop.jar
constituent[14]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/javax.inject-1.jar
constituent[15]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/jsoup-1.7.2.jar
constituent[16]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/jsr250-api-1.0.jar
constituent[17]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-aether-provider-3.3.9.jar
constituent[18]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-artifact-3.3.9.jar
constituent[19]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-builder-support-3.3.9.jar
constituent[20]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-compat-3.3.9.jar
constituent[21]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-core-3.3.9.jar
constituent[22]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-embedder-3.3.9.jar
constituent[23]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-model-3.3.9.jar
constituent[24]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-model-builder-3.3.9.jar
constituent[25]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-plugin-api-3.3.9.jar
constituent[26]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-repository-metadata-3.3.9.jar
constituent[27]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-settings-3.3.9.jar
constituent[28]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/maven-settings-builder-3.3.9.jar
constituent[29]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/org.eclipse.sisu.inject-0.3.2.jar
constituent[30]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/org.eclipse.sisu.plexus-0.3.2.jar
constituent[31]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/plexus-cipher-1.7.jar
constituent[32]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/plexus-component-annotations-1.6.jar
constituent[33]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/plexus-interpolation-1.21.jar
constituent[34]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/plexus-sec-dispatcher-1.3.jar
constituent[35]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/plexus-utils-3.0.22.jar
constituent[36]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/slf4j-api-1.7.5.jar
constituent[37]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/slf4j-simple-1.7.5.jar
constituent[38]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/wagon-file-2.10.jar
constituent[39]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/wagon-http-2.10-shaded.jar
constituent[40]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/wagon-http-shared-2.10.jar
constituent[41]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/lib/wagon-provider-api-2.10.jar
constituent[42]: file:/C:/Users/BernardPaulus/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9/conf/logging/
---------------------------------------------------
Exception in thread "main" java.lang.reflect.InvocationTargetException
        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 java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
        at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
        at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:50)
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:147)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:117)
        at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:425)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at com.sun.tools.xjc.Driver.run(Driver.java:333)
        at org.codehaus.mojo.jaxb2.AbstractXjcMojo.execute(AbstractXjcMojo.java:316)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        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.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        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 java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
        ... 7 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
        ... 36 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
        at com.sun.tools.xjc.reader.xmlschema.BindingComponent.getClassSelector(BindingComponent.java:65)
        at com.sun.tools.xjc.reader.xmlschema.ColorBinder.<init>(ColorBinder.java:62)
        at com.sun.tools.xjc.reader.xmlschema.BindGreen.<init>(BindGreen.java:63)
        ... 41 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
        ... 44 more
Caused by: java.lang.NoClassDefFoundError: javax/activation/MimeTypeParseException
        at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3090)
        at java.base/java.lang.Class.getConstructor0(Class.java:3295)
        at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2512)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:100)
        at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.<init>(DefaultClassBinder.java:98)
        at com.sun.tools.xjc.reader.xmlschema.ClassSelector.<init>(ClassSelector.java:214)
        ... 49 more
Caused by: java.lang.ClassNotFoundException: javax.activation.MimeTypeParseException
        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)
        ... 56 more

When I change my JDK to jdk1.8.0_172, it all works.

I can't spend more time on this right now, but I thought I should report the issue :)

Kind regards,

Bernard

Add Validations

Maybe it'll be very useful (it took me a couple of hours to find the way) to document the way of validate the request using only configurations...

@Override public void addInterceptors(List<EndpointInterceptor> interceptors) { PayloadValidatingInterceptor validatingInterceptor = new PayloadValidatingInterceptor(); validatingInterceptor.setValidateRequest(true); validatingInterceptor.setValidateResponse(true); validatingInterceptor.setXsdSchema(countriesSchema()); interceptors.add(validatingInterceptor); }

Thanks for your guides! They rock

Support for jdk 11

I was trying this exercise on jdk11 with no luck yet. Dealing with jaxb xml xsd soap is a complete mess now with 11.
Can you please us by updating this example with latest jdk

Gradle config doesn't work under Java 11

Gradle config needs to be updated to work under Java 11. I have opened a pull request (#26) for a fix under the complete folder. Unsure if you need to update the documentation to reflect the change.

The method setApplicationContext(ApplicationContext) is undefined for the type MessageDispatcherServlet

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

In the above method,
servlet.setApplicationContext(applicationContext);

gives an error

The method setApplicationContext(ApplicationContext) is undefined for the type MessageDispatcherServlet

when checked the API of MessageDispatcherServlet, there isn't any method setApplicationContext.

Please Help.

jaxb2-maven-plugin generates sources in incorrect location

The jaxb2-maven-plugin is configured to output the generated sources and not clear the output directory:

<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>

This is not desirable for 2 reasons:

  • It's generally considered best to store generated code together with the normal project code. (See this stackoverflow question for a discussion.)
  • Because the code generation shouldn't delete the normal sources, the clearOutputDir option is set to false. This has the unhappy side effect that certain changes to the XSD would not be correctly represented in the generated code. (e.g.: Deletion of an XML element in the XSD would not remove the generated java class.)

Question : Why can my build not find jaxb2-maven-plugin version 2.5.0?

When Adding the jaxb2-maven-plugin plugin to my code the version 2.5.0 does not exist and I have to change it to 1.6 which then renders the sources XML tag invalid (error "element is not allowed here").

I must admit I did not compile your code I just added the plugin required for the XSD and off cause the other dependencies for the SOAP web service.
My spring release is 2.2.4.RELEASE
JVM 1.8

XJC Arguments

Hi,
How can I add argument to the generated java classes, I would like to add toString, hashcode and equals to the classes

but when I try this I get an error

xjc(destdir: sourcesDir, schema: schema, package: 'io.spring.guides.gs_producing_web_service') {
        arg(line: "-wsdl -Xequals -XhashCode -XtoString")
        produces(dir: sourcesDir, includes: "**/*.java")
}
Execution failed for task ':genJaxb'.
> unrecognized parameter -Xequals

Upgrade Spring Boot to the latest version

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

To do so, change the Spring Boot version in:

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

It seems like on windows "${project.basedir}" does not find the files

On windows this result in (I replaced the counties.xsd with response.xsd)
${project.basedir}/src/main/resources/templates/response.xsd

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< africa.absa:training1 >------------------------
[INFO] Building training1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- jaxb2-maven-plugin:2.5.0:schemagen (default-cli) @ training1 ---
[WARNING]
+=================== [Incorrect Plugin Configuration Detected]
|
| Property : sources
| Problem : At least one Java Source file has to be included.
|
+=================== [End Incorrect Plugin Configuration Detected]

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.257 s
[INFO] Finished at: 2020-11-26T10:32:02+02:00
[INFO] ------------------------------------------------------------------------

When changing the the source to us baseUri rather (this worked for when using the WSDL generator)
${project.baseUri}/src/main/resources/templates/response.xsd

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< africa.absa:training1 >------------------------
[INFO] Building training1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- jaxb2-maven-plugin:2.5.0:schemagen (default-cli) @ training1 ---
[INFO] Ignored given or default sources [file:///C:/Users/abjmalu/git/springboot/training1//src/main/resources/templates/response.xsd], since it is not an existent file or directory.
[WARNING]
+=================== [Incorrect Plugin Configuration Detected]
|
| Property : sources
| Problem : At least one Java Source file has to be included.
|
+=================== [End Incorrect Plugin Configuration Detected]

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.508 s
[INFO] Finished at: 2020-11-26T10:34:23+02:00
[INFO] ------------------------------------------------------------------------

The file definitely does exist and the URL generated resolves to the file so I don't know why the plugin cant find the file

Your help will be appreciated.

thanks

Jacques

No endpoint mapping found for `[SaajSoapMessage {http://api.com}getCountryRequest]`

Every time I try to run the application, I get the following error: No endpoint mapping found for [SaajSoapMessage {http://api.com}getCountryRequest]. I have been trying to expose listed endpoints like mentioned on Stack Overflow, but has no effect. I also attempted to add the following code to the application.properties file:

    spring.webservices.expose-all-endpoints=true

But it doesn't work. Then I set out to add another code to the application.properties file:

management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans

But it doesn't work either. I have been attempting to solve this problem for a long time, but I can't find a solution. I would be genuinely grateful if you could help me. Thank you in advance.

note: To re-create the issue, here is my repo

Improve gradle configuration for java classes generation with xjc

Currently java classes are generated from XSD with an ant task which involve XJC. This is fine, but this ant task also compile classes and copy them into expected classes directory. This is problematic in several aspects:

  • This compile phase does not rely on gradle configuration for java compilation, thus it is currently configured for a java 1.6 target whereas project target java 1.8
  • The generated sources are not properly configured as extra sources in gradle, thus plugin like Google Jib failed to properly find generated classes

Try to run the complete gradle project and it failed to compile

I download the complete project, clean up the maven related and left gradle part, load the project as gradle project into intellij. But when I try to run the project, it failed on compile following:

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

MessageDispatcherServlet doesn't have method called setApplicationContext
and also ServletRegistrationBean doesn't have constructor for MessageDispatcherServelt and String.

What I need to fix to make it work?

How to perform security?

Do you have any guides on how to implement ws-security on a soap server like this one?
We are looking for a encryption of our SOAP content and a authentication on the SOAP.

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.