0

I want to create a contract first Spring webservice. So I have the WSDL file, but I can't find any example of generating the Spring webservices from the WSDL.

With this Maven plugin, I can generate it, but it will be a J2EE WebService, and not a Spring WebService, am I Right?:

<plugin>
    <groupId>org.jvnet.jax-ws-commons</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <configuration>
        <xdebug>true</xdebug>
        <verbose>true</verbose>
        <target>2.0</target>
    </configuration>
    <executions>
        <execution>
            <id>generate-service</id>
            <goals>
                <goal>wsimport</goal>
            </goals>
            <configuration>
                <wsdlDirectory>src/main/resources/wsdls</wsdlDirectory>
                <wsdlFiles>
                    <wsdlFile>service.wsdl</wsdlFile>
                </wsdlFiles>
                <sourceDestDir>target/generated-code/src</sourceDestDir>
            </configuration>
        </execution>
    </executions>
</plugin>

This will generate an interface, which has the @WebService annotation. But this is for the J2EE application, and not Spring, right?

So, is there any tool in maven for generate Spring WebServices from an already written WSDL file?

Because I cannot find any, only the jaxws-Maven-plugin.

victorio
  • 6,224
  • 24
  • 77
  • 113

1 Answers1

1

You can surely use :

http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html

or http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/example_xjc_basic.html

or even https://java.net/projects/maven-jaxb2-plugin/pages/Home

Then you'll just have to create a jaxws:client in spring : http://cxf.apache.org/docs/jax-ws-configuration.html

Or just the cxf component in camel : http://camel.apache.org/cxf.html

J2EE is nothing more than a stack, a collection of framework that forms a collection. You can use CXF/Spring with another Framework (such as OSGi) and just import what interests you (for example, camel-cxf, spring-core, ...). For example, I'm working on an OSGi environment, but we are using codegen plugin to generate the class and then integrate them with camel-cxf.

Jonathan Schoreels
  • 1,660
  • 1
  • 12
  • 20
  • But this cxf-codegen-plugin will create @WebService annotations for the interfaces too. Is this good for Spring application? Isn't it J2EE architect? – victorio Mar 22 '16 at 20:56
  • 1
    J2EE is nothing more than a stack, a collection of framework that forms a collection. You can use CXF/Spring with another Framework (such as OSGi) and just import what interests you (for example, camel-cxf, spring-core, ...). For example, I'm working on an OSGi environment, but we are using codegen plugin to generate the class and then integrate them with camel-cxf. – Jonathan Schoreels Mar 22 '16 at 21:02
  • JavaEE, not J2EE because that's been retired for a decade now, is a set of specifications forming one verifiable standard for a JavaEE application server. The implementations of that standard - Wildfly, Glassfish, TomEE, etc. are the true stacks. – Gimby Mar 23 '16 at 12:59