Create WSDL from java with maven: target CXF + java2ws

Does it have a meaningful tutorial that shows how to create WSDL from java code using maven and cxf goal java2ws?

I want to run mvn install on a project containing the annotated @WebService class and create a WSDL somewhere inside the target folder so that another developer can use it to create subscriber classes.

I also want the Webservice to be included in the bank, which I can deploy inside the WebService container so that the service is available to the subscriber.

So far my pom looks like this:

 <properties> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <cxf.version>2.2.3</cxf.version> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.version}</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>2.0.9</version> </dependency> </dependencies> <executions> <execution> <id>generate-wsdl</id> <phase>process-classes</phase> <goals> <goal>java2ws</goal> </goals> <configuration> <outputFile>${project.build.outputDirectory}/testService.wsdl</outputFile> <className>complete.path.to.ClassName</className> <verbose>true</verbose> </configuration> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> <pluginRepositories> <pluginRepository> <id>apache-snapshots</id> <name>Apache SNAPSHOT Repository</name> <url>http://repository.apache.org/snapshots/</url> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> <repositories> <repository> <id>apache-snapshots</id> <name>Apache SNAPSHOT Repository</name> <url>http://repository.apache.org/snapshots/</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/2/</url> <layout>default</layout> </repository> </repositories> <dependencies> <!-- CXF WebService --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>${cxf.version}</version> </dependency> </dependencies> 

But when I run maven install .. no wsdl ..

Oh, well, additional information: We are developing modularly. The module that the WebService provides will contain other classes that handle internal method calls from the frontend module and will be created as a bank, not a war.

Hope someone finds what I am missing, or can point me to a good tutorial.

EDIT: The target is called directly using mvn org.apache.cxf:cxf-java2ws-plugin:java2ws , but I get a LifecycleExecutionException :

 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-java2ws-plugin:2.2.3:java2ws (default-cli) on project dw-person: The parameters 'className' for goal o rg.apache.cxf:cxf-java2ws-plugin:2.2.3:java2ws are missing or invalid at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:221) 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:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'className' for goal org.apache.cxf:cxf-java2ws-plugin:2.2.3:java2ws are missing or invalid at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:576) at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:529) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more 

The className parameter exists, as seen above, and the path is correct ... Any ideas?

+4
source share
3 answers

It seems that the <pluginManagement> unknown. If I remove it (and upgrade to cxf version 2.5), everything will work fine even for .jar packaging.

I donโ€™t know why this can be found everywhere on the Internet with a tag. It is also interesting why these errors are not detected or maven is logged. Sigh...

+1
source
 Good Read - http://united-coders.com/phillip-steffensen/developing-a-simple-soap-webservice-using-spring-301-and-apache-cxf-226 <project xmlns="..."> <modelVersion>4.0.0</modelVersion> <groupId>com.unitedcoders.demo</groupId> <artifactId>CXFExampleService</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>Example Apache CXF Webservice</name> <url>http://united-coders.com</url> <!-- Dependency properties --> <properties> <junit-version>4.5</junit-version> <cxf.version>2.2.6</cxf.version> <spring-version>3.0.1.RELEASE</spring-version> <commons-logging-version>1.1.1</commons-logging-version> </properties> <!-- Plugin configuration --> <build> <finalName>CXFExampleService</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-java2ws-plugin</artifactId> <version>${cxf.version}</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-simple</artifactId> <version>${cxf.version}</version> </dependency> </dependencies> <executions> <execution> <id>process-classes</id> <phase>process-classes</phase> <configuration> <className>com.unitedcoders.demo.PersonService</className> <genWsdl>true</genWsdl> <verbose>true</verbose> </configuration> <goals> <goal>java2ws</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <!-- Dependency definitions --> <dependencies> <!-- Apache CXF dependencies --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency> <!-- Spring Dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring-version}</version> </dependency> <!-- Logging --> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>${commons-logging-version}</version> </dependency> <!-- Testing --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit-version}</version> <scope>test</scope> </dependency> </dependencies> </project> 
0
source

Just for those who have problems not related to pluginManagement . In my case for cxf.version 3.1.10, the question was about placing the <configuration> section. By moving it to the same level as <executions> , the problem disappeared. I found it here: http://cxf.547215.n5.nabble.com/Strange-behavior-of-Maven-cxf-java2ws-plugin-td553742.html

Here is an example from apache.org ( https://cxf.apache.org/docs/maven-java2ws-plugin.html ):

 <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-java2ws-plugin</artifactId> <version>${cxf.version}</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> </dependencies> <executions> <execution> <id>process-classes</id> <phase>process-classes</phase> <configuration> <className>full.class.name</className> <genWsdl>true</genWsdl> <verbose>true</verbose> </configuration> <goals> <goal>java2ws</goal> </goals> </execution> </executions> </plugin> 

And here one thing is fixed:

 <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-java2ws-plugin</artifactId> <version>${cxf.version}</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> </dependencies> <configuration> <className>full.class.name</className> <genWsdl>true</genWsdl> <verbose>true</verbose> </configuration> <executions> <execution> <id>process-classes</id> <phase>process-classes</phase> <goals> <goal>java2ws</goal> </goals> </execution> </executions> </plugin> 
0
source

Source: https://habr.com/ru/post/1382458/


All Articles