Knowing the dependencies amongst your jars.

It may happen often that we include a bunch of jar files in our project, but not sure about their usage. We do it many a times as we want to avoid any unforseen errors, and most of the times just for saving time’s sake which we have to spend examining each’s utility.

I too did the same, until yesterday when I intentionally started removing the jars whose utility I couldn’t directly see, and there awaited a lot of surreal surprises, and of course a plethora of errors, which I don’t normally see, all because of an inquisitive idea!

This post will again extol maven.ย There were days when I would just loath this word, for it required me to change my directory structure and write an additional file, POM. But gone are those days, and my ignorance about it.

Let’s take a sample POM.


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>ankeet.spring.aop</groupId>
 <artifactId>spring-aop-sample</artifactId>
 <version>1.0-SNAPSHOT</version>
 <packaging>jar</packaging>
 <name>spring-aop-sample</name>
 <url>http://maven.apache.org</url>
 <properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>
 <dependencies>
<dependency>
 <groupId>cglib</groupId>
 <artifactId>cglib-nodep</artifactId>
 <version>2.2.2</version>
 </dependency>
 <dependency>
 <groupId>org.aspectj</groupId>
 <artifactId>aspectjweaver</artifactId>
 <version>1.6.12</version>
 </dependency>
 <dependency>
 <groupId>org.aspectj</groupId>
 <artifactId>aspectjrt</artifactId>
 <version>1.6.12</version>
 </dependency>
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>3.8.1</version>
 <scope>test</scope>
 </dependency>
 </dependencies>
</project>

Now when I save it in STS, the maven plugin downloads these dependencies and adds them to my classpath.

So, no surprise there, four dependency declarations and four dependencies listed above.

Now, add one more dependency to your POM and save it.

<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-context</artifactId>
 <version>3.1.0.RELEASE</version>
 </dependency>

We just added a spring-context dependency to our project. Now we’ll see the dependencies included in the project with the inclusion of this new one.

What in the world???

We just included one single dependency!!

From where have all these come from?

It’s okay, don’t panic there’s no error, or virus for that matter. ๐Ÿ™‚

By now you must have guessed, these extra jars are the dependencies of spring-contextย dependency. Spring-context depends on them directly or indirectly, so you have to include all those in your classpath but if you use maven, it’ll do it automatically for you. ๐Ÿ™‚

To know it in a more detailed manner, type

mvn dependency:tree

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-aop-sample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ spring-aop-sample ---
[INFO] ankeet.spring.aop:spring-aop-sample:jar:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:3.1.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:3.1.0.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:3.1.0.RELEASE:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | +- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
[INFO] | \- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.6.12:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.6.12:compile
[INFO] \- junit:junit:jar:3.8.1:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.297s
[INFO] Finished at: Tue Dec 20 11:32:02 IST 2011
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------

So you can see how spring-context is dependent on spring-aop and spring-aop inturn is dependent on aopalliance.

There are several other useful goals of this maven dependency plugin like analyze. You can check them here.

I hope you’ll too have fun discovering the very jars you unknowingly used and their obscurely hidden interdependencies. ๐Ÿ™‚

Managing Maven and it’s versions. Made Easy!

Maven is a fantastic tool for building Java codes, and makes the process very easy and efficient. The dependency management in Maven is done by just declaring them along with the version numbers. Sometimes, managing different versions becomes extremely tedious, as it involves searching the corresponding element in POM and then changing the version number if you need to upgrade it.

When creating new projects using maven-archetypes, although it generates the POM automatically, with the basic minimum dependencies declared along with the information of plugins, but sometimes misses their versions, which makes it highly susceptible to build errors, and can also lead to total build failure if it’s built with newer versions of Apache Maven.

Let’s just quickly see a scenario like above. We’ll create the project using maven-archetypes and maven itself will give us near fatal warnings when we try to compile it ๐Ÿ™‚

Type this in your command prompt, in one single line.

mvn archetype:create -DarchetypeGroupId=org.springframework.ws -DarchetypeArtifactId=spring-ws-archetype -DarchetypeVersion=2.0.1.RELEASE -DgroupId=version.demo -DartifactId=version-demo

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-archetype-plugin:2.1:create (default-cli) @ standalone-pom ---
[WARNING] This goal is deprecated. Please use mvn archetype:generate instead
[INFO] Defaulting package to group ID: version.demo
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: spring-ws-archetype:2.0.1.RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: version.demo
[INFO] Parameter: packageName, Value: version.demo
[INFO] Parameter: package, Value: version.demo
[INFO] Parameter: artifactId, Value: version-demo
[INFO] Parameter: basedir, Value: F:\
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: F:\version-demo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.455s
[INFO] Finished at: Fri Dec 16 00:13:12 IST 2011
[INFO] Final Memory: 6M/11M
[INFO] ------------------------------------------------------------------------

Now, you have the project, go to the root, and do an mvn compile

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for version.demo:version-demo:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 14, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building version-demo Spring-WS Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ version-demo ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ version-demo ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.974s
[INFO] Finished at: Fri Dec 16 00:16:59 IST 2011
[INFO] Final Memory: 2M/6M
[INFO] ------------------------------------------------------------------------

So, did you see the warnings?

And we did nothing wrong, created the project from maven-archetype, and then simply compiled it. But due to the missing versions of the plugins, we see these warnings. This is a small POM but in a big project, the POM may be very large, so manual finding of these and rectifying seems an uphill task.

Enter mvn versions plugin – The Panacea for you ๐Ÿ™‚

Type in mvn versions:display-plugin-updates

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for version.demo:version-demo:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 14, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building version-demo Spring-WS Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:1.2:display-plugin-updates (default-cli) @ version-demo ---
[INFO] artifact org.codehaus.mojo:tomcat-maven-plugin: checking for updates from central
[INFO]
[INFO] All plugins with a version specified are using the latest versions.
[INFO]
[WARNING] The following plugins do not have their version specified:
[WARNING] maven-compiler-plugin .................................. (unknown)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.742s
[INFO] Finished at: Fri Dec 16 00:27:23 IST 2011
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------

So it will tell you whose versions you have missed and you can change easily. I’ll update the version to 2.3.2, after I looked it up at http://mirrors.ibiblio.org/.ย It’ll also tell you which dependency has a new version available also. Just type in the following to check your dependencies.

mvn versions:display-dependency-updates

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building version-demo Spring-WS Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:1.2:display-dependency-updates (default-cli) @ version-demo ---
[INFO] No dependencies in Dependencies are using the newest version.
[INFO]
[INFO] The following dependencies in Dependencies have newer versions:
[INFO] org.springframework.ws:spring-ws-core ...
[INFO] 2.0.1.RELEASE -> 2.0.3.RELEASE
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.900s
[INFO] Finished at: Fri Dec 16 00:41:46 IST 2011
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------

It doesn’t stop here, it even goes a step further and changes your POM to use all the latest versions. All you have to do is

mvn versions:use-latest-versions and voila you’re done!

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building version-demo Spring-WS Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:1.2:use-latest-versions (default-cli) @ version-demo ---
[INFO] Updated org.springframework.ws:spring-ws-core:jar:null:2.0.1.RELEASE to version 2.0.3.RELEASE
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.096s
[INFO] Finished at: Fri Dec 16 00:42:55 IST 2011
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------

You can dig more into this plugin at it’s official site. It’s of great help, but only lesser known.

That’s all for this one. Happy versioningย ย ๐Ÿ™‚

Spring Web Services Client

In this post we’ll develop a Spring WebService client which will consume the Webservice we created in the previous post, getSquareService. This getSquareService takes in an integer as an input and gives back its square via http using spring web services 2.0. Earlier we used a Soap UI, to test and send/recieve our request/response, but now we’ll develop our own client as in real applications.

This client will be a normal Spring MVC application. As far as content is concerned, we’ll use two things here:-

  1. Web Service Template by Spring: This web service templates, makes our client code, extremely easy and good. It’s a helper template just as in JDBCTemplate, which is to access database using jdbc.
  2. wsimport tool by JAX-WS: This tool, takes in the wsdl url, and generates the Java Proxy classes and other artifacts which are necessary to consume the webservice.

Let’s start developing our client to the webservice. You don’t have to copy paste, the source code is shared and can be downloaded easily.

Downloadย source code.

You can see the older version from here. The current version incorporates the changes required to comply with Maven 3

Now, since you have the source code at your disposal, let’s start it from the very beginning ๐Ÿ™‚

Developing the Web Service Client from scratch!

1. Download the webservice project created in the earlier post Spring Web Services 2. Made Easy!ย and import it using Existing Maven Projectsย in your STS/Eclipse. (I use SpringSourceToolSuite, STS in short, though!)

2. Now open up your browser and type in the following URL to see the WSDL generated and examine it.

http://localhost:8080/spring-ws2-exemplary/getSquare.wsdl

3. Download the wsimport tool and execute it by following the instructions and set the path of it’s bin folder in your classpath.

4. Now we’ll use wsimport tool to generate our Java classes, as we generated it for jaxb.

5. Open command prompt and enter the following command to generate the classes at some place.

wsimport -d F:\generated -keep http://localhost:8080/spring-ws2-exemplary/getSquare.wsdl

Make sure the target directory already exists. Below is the screeen shot of this command.

Now check at the target place for the files generated, F:\Generated in my case.

6. Create the project by executing the following command in a single line.

mvn archetype:generate -DgroupId=ankeet.ws2.client -DartifactId=spring-ws2-client -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

7. Open your STS/Eclipse and import the above as Existing Maven Projects. This import option will come only if you have maven plugin installed for your IDE. With STS it comes in built, but you need to install it explicitly for Eclipse. Else do an mvn eclipse:eclipse and then import as Existing Projects in workspace.

8. Create a new source folder and in it a packageย com.wordpress.ankeetmaini.spring_ws2_squareย and copy all the .java files created earlier by wsimport.

9. Create another package ankeet.spring.ws2.controller, where we’ll create the Controller of our Client App. Call it ClientController.java

/**</pre>
 *
 */
package ankeet.spring.ws2.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.ws.client.core.WebServiceTemplate;

import com.wordpress.ankeetmaini.spring_ws2_square.ObjectFactory;
import com.wordpress.ankeetmaini.spring_ws2_square.SquareServiceRequest;
import com.wordpress.ankeetmaini.spring_ws2_square.SquareServiceResponse;

/**
 * @author Ankeet Maini
 *
 */
@Controller
@RequestMapping("/")
public class ClientController {
 @Autowired
 private WebServiceTemplate webServiceTemplate;

 /**
 * This is the default handler. When application goes live
 * the control comes to this, and it fires a JSP,
 * asking the input.
 */
 @RequestMapping(method = RequestMethod.GET)
 public String getRequest(Model model) {
 model.addAttribute("squareServiceRequest", new ObjectFactory().createSquareServiceRequest());
 //Show request.jsp
 return "request";
 }

 /**
 * This is the handler, which takes in the input number, and calculates
 * the square by taking it from the webservice, via WebServiceTemplate, and then finally
 * sets as a ModelAttribute, which in turn is shown by "response.jsp"
 */
 @RequestMapping(method = RequestMethod.POST)
 public String showResponse(@ModelAttribute SquareServiceRequest squareServiceRequest, Model model) {
 //Creating the SquareServiceResponse object.
 SquareServiceResponse squareServiceResponse = new ObjectFactory().createSquareServiceResponse();
 //Sending the request object via WebServiceTemplate and getting back the response from WebService ๐Ÿ™‚
 squareServiceResponse = (SquareServiceResponse) webServiceTemplate.marshalSendAndReceive(squareServiceRequest);
 //This was supposed to be a hard part. Piece of cake ๐Ÿ™‚
 model.addAttribute("squareServiceResponse", squareServiceResponse);
 //Show response.jsp
 return "response";
 }

}
<pre>

10. Create a folder “views” inside WEB-INF to keep your JSP files. Inside the “views” folder create two JSP files:

  1. request.jsp ย  ย -> This will ask user a number whose square is to be calculated using WebService: getSquare.
  2. response.jsp -> This will show the user calculated square, which came in response from getSquare webservice.

request.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page session="false" %>

<html>
<head>
<%@ page isELIgnored="false" %>
<title>Square Webservice 2 Client</title>
</head>
<body>
 <form:form commandName="squareServiceRequest" method="post">
 <table>
 <tr>
 <td>Enter Number:</td>
 <td><form:input path="input"/></td>
 <td><font color="red"><form:errors path="input"/></font></td>
 </tr>
 </table>
 <input name="submit" type="submit" value="Get it's square!" />
 </form:form>
</body>
</html>

response.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>
<%@ page isELIgnored="false" %>
<title>Square Webservice 2 Client</title>
</head>
<body>
 The square of the entered number is: <b><font color="red" size="3">${squareServiceResponse.output}</font></b>
 <br />
 <br /> This is brought to you by <i>Spring Webservices 2</i> and <font color="blue" size="4.5"><b>Ankeet Maini</b></font> ๐Ÿ™‚
</body>
</html>

11. Define your web.xml. Make sure web.xml is directly inside the WEB-INF.


<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
 <display-name>Archetype Created Web Application</display-name>
 <servlet>
 <servlet-name>spring-ws2-client</servlet-name>
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
 <servlet-name>spring-ws2-client</servlet-name>
 <url-pattern>/</url-pattern>
 </servlet-mapping>
</web-app>

12. Create your spring-ws2-client-servlet.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
 xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:sws="http://www.springframework.org/schema/web-services"
 xmlns:p="http://www.springframework.org/schema/p"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-3.0.xsd
 http://www.springframework.org/schema/web-services
 http://www.springframework.org/schema/web-services/web-services-2.0.xsd
 http://www.springframework.org/schema/mvc
 http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

 <!-- Activates various annotations to be detected in bean classes -->
 <context:annotation-config />

<!-- Scans the classpath for annotated components that will be auto-registered
 as Spring beans. For example @Controller and @Service. Make sure to set the
 correct base-package -->
 <context:component-scan base-package="ankeet.spring" />
 <context:component-scan base-package="com.wordpress" />

<!-- Configures the annotation-driven Spring MVC Controller programming
 model. Note that, with Spring 3.0, this tag works in Servlet MVC only! -->
 <mvc:annotation-driven />
 <!-- Declare a view resolver -->
 <bean id="viewResolver"
 class="org.springframework.web.servlet.view.InternalResourceViewResolver"
 p:prefix="/WEB-INF/views/" p:suffix=".jsp" />

 <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"
 p:marshaller-ref="jaxbMarshaller"
 p:unmarshaller-ref="jaxbMarshaller"
 p:defaultUri="http://localhost:8080/spring-ws2-exemplary/squareService"
 p:messageSender-ref="messageSender">
 <constructor-arg ref="messageFactory"/>
 </bean>
 <bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender"/>
 <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
 <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"
 p:contextPath="com.wordpress.ankeetmaini.spring_ws2_square"/>

</beans>

13. Lastly, define your POM.xml file so that maven can provide for all your dependencies.


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>ankeet.ws2.client</groupId>
 <artifactId>spring-ws2-client</artifactId>
 <packaging>war</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>spring-ws2-client Maven Webapp</name>
 <url>http://maven.apache.org</url>
 <dependencies>
 <dependency>
 <groupId>javax.xml.bind</groupId>
 <artifactId>jaxb-api</artifactId>
 <version>2.0</version>
 </dependency>
 <dependency>
 <groupId>com.sun.xml.bind</groupId>
 <artifactId>jaxb-impl</artifactId>
 <version>2.0.3</version>
 </dependency>
 <dependency>
 <groupId>org.apache.xmlbeans</groupId>
 <artifactId>xmlbeans</artifactId>
 <version>2.4.0</version>
 </dependency>
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>3.8.1</version>
 <scope>test</scope>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-beans</artifactId>
 <version>3.0.5.RELEASE</version>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-context</artifactId>
 <version>3.0.5.RELEASE</version>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-context-support</artifactId>
 <version>3.0.5.RELEASE</version>
 </dependency>
 <dependency>
 <groupId>org.springframework.ws</groupId>
 <artifactId>spring-ws-core</artifactId>
 <version>2.0.3.RELEASE</version>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-web</artifactId>
 <version>3.0.5.RELEASE</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-core</artifactId>
 <version>3.0.5.RELEASE</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>1.2.14</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-tx</artifactId>
 <version>3.0.5.RELEASE</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>jstl</groupId>
 <artifactId>jstl</artifactId>
 <version>1.1.2</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>taglibs</groupId>
 <artifactId>standard</artifactId>
 <version>1.1.2</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-webmvc</artifactId>
 <version>3.0.5.RELEASE</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-aop</artifactId>
 <version>3.0.5.RELEASE</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>

<dependency>
 <groupId>commons-httpclient</groupId>
 <artifactId>commons-httpclient</artifactId>
 <version>3.1</version>
 <type>jar</type>
 <scope>compile</scope>
 </dependency>
 </dependencies>
 <build>
 <finalName>spring-ws2-client</finalName>
 </build>
</project>

14. Check your directory structure. Make sure you are not missing anything, neither the resource, nor the structure.

15. To run this web client, first run the webservice, spring-ws2-exemplary project, download it from here.

16. Run the client now. The project is hosted on google codes.ย Download it from here.ย Now, run the client by importing it as Existing Maven Projects.

Enter the number, and press the button.

That’s all folks. If you come across any problem, do let me know, and if you do go a step further and do some improvements then do share it here, and I’ll incorporate into the post citing your name and contribution. ๐Ÿ™‚