How to create a webservice client with Maven and JAX-WS
Maven allows you to integrate the generation of a JAX-WS webservice client into your build process. To do this, do the following:
1. Create a new module for the webservice client in your maven project.
2. Add the following configuration to the pom.xml of the new module:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>nl.interact.ipds.agentvi.connector.schema</packageName>
<wsdlUrls>
<wsdlUrl>http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl</wsdlUrl>
</wsdlUrls>
<extension>true</extension>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.jvnet</groupId>
<artifactId>mimepull</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
3. The jar that maven generates with the above config, can be used to write a client program like the following:
MovieInformation info = new MovieInformation();
ArrayOfTheater theaters = info.getMovieInformationSoap12().getTheatersAndMovies(“10001″, 1);
for (Theater t : theaters.getTheater()) {
System.out.println(“Theatre: “+t.getName()+”, “+t.getAddress());
ArrayOfMovie movies = t.getMovies();
for (Movie m : movies.getMovie()) {
System.out.println(” -”+m.getName()+”, (Rating: “+m.getRating()+”)”);
}
}
Categories: Java, Maven3
Code Generation, JAX-WS
Comments (0)
Trackbacks (0)
Leave a comment
Trackback