javamaven-2wsdlwsdl2code

WSDL consume - What tool to use?


I'm having trouble understanding how to make a web service client. The story is that I need to make a call to a web service. As I then understand it I need to somehow consume the web service to get the correct classes of the web service.

I've investigated a numerous of ways to do this. For example I've tried consuming them with a script and then just import the classes.

However, a colleague of my recommended that I would try using the Maven-plugin wsdl2code since we already use Maven-2 . Doing this works but creates a lot of junk files as I see it. I've added following into my pom.xml file:

<plugin>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
    <version>1.4</version>
     <executions>
         <execution>
            <goals>
                <goal>wsdl2code</goal>
            </goals>
            <configuration>
                <packageName>ws.client.test</packageName>
                <wsdlFile>http://localhost:8088/test?WSDL</wsdlFile>
                <databindingName>xmlbeans</databindingName>
                <outputDirectory>target/ws/test</outputDirectory>
            </configuration>
         </execution>
      </executions>
</plugin>

This creates the files successfully, but as said, there's also a lot of junk files( xmlsoap/schemas/soap/encoding/...) or at least a lot more files for no use (as I see it) than the other WSDLconsume I tried.

Questions

Update/Edit
By using for example JAX-WS wsimport I get the generated files that I desire. However, by having these created in the /target-folder I want to reach them in the same project to actually call the web service. Is this possible?


Solution

  • If you have java-1.6 you can (should) use jax-ws, its very easy with onboard java tools. There is a good maven plugin that will create a webservice client, that can be used without any additional dependencies. Have a look at http://jax-ws-commons.java.net/jaxws-maven-plugin/

    See http://blogs.oracle.com/enterprisetechtips/entry/using_jax_ws_with_maven for a detailed walkthrough.