<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tejakantamneni's Weblog</title>
	<atom:link href="http://tejakantamneni.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tejakantamneni.wordpress.com</link>
	<description>A compilation of my thoughts and lessons learnt</description>
	<lastBuildDate>Tue, 07 Feb 2012 01:22:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tejakantamneni.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tejakantamneni's Weblog</title>
		<link>http://tejakantamneni.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tejakantamneni.wordpress.com/osd.xml" title="Tejakantamneni&#039;s Weblog" />
	<atom:link rel='hub' href='http://tejakantamneni.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Installing Rhino on mac</title>
		<link>http://tejakantamneni.wordpress.com/2010/08/11/installing-rhino-on-mac/</link>
		<comments>http://tejakantamneni.wordpress.com/2010/08/11/installing-rhino-on-mac/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 02:34:53 +0000</pubDate>
		<dc:creator>tejakantamneni</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[rhino]]></category>

		<guid isPermaLink="false">http://tejakantamneni.wordpress.com/?p=21</guid>
		<description><![CDATA[From Rhino : Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users. Rhino is an implementation of JavaScript in Java. Features include full implementation of JavaScript 1.7 and allows direct scripting of Java and more&#8230; There are some good frameworks [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=21&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>From Rhino :</p>
<blockquote><p>Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users.</p></blockquote>
<p>Rhino is an implementation of JavaScript in Java. Features include full implementation of JavaScript 1.7 and allows direct scripting of Java and more&#8230;</p>
<p>There are some good frameworks available like this one from my friend Fred Polgrady, http://github.com/sustainablecode/datastore</p>
<p>I will provide an easy way of installing Rhino on a mac. Follow these three steps for an easy installation&#8230;</p>
<p>1. Download Rhino</p>
<p>2. Create &#8220;Java/Extensions&#8221; in home directory &#8220;~/Library/Java/Extensions&#8221;</p>
<p>3. Copy the js.jar file from the downloaded Rhino zip file to &#8220;Extensions&#8221; directory.</p>
<p>Thats it!! You are all set to use Rhino.</p>
<p>$ java org.mozilla.javascript.tools.shell.Main</p>
<p>Rhino 1.7 release 2 2009 03 22</p>
<p>js&gt; eval(&#8220;print(&#8216;hello&#8217;)&#8221;)</p>
<p>hello</p>
<p>Thats all!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tejakantamneni.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tejakantamneni.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tejakantamneni.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tejakantamneni.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tejakantamneni.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tejakantamneni.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tejakantamneni.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tejakantamneni.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tejakantamneni.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tejakantamneni.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tejakantamneni.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tejakantamneni.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tejakantamneni.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tejakantamneni.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=21&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tejakantamneni.wordpress.com/2010/08/11/installing-rhino-on-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d555c04f1b80fbe575c122979fd25e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tejakantamneni</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Servlet Specification 3.0 &#8211; Overview and Quick Intro</title>
		<link>http://tejakantamneni.wordpress.com/2010/08/09/java-servlet-specification-3-0-overview-and-quick-intro/</link>
		<comments>http://tejakantamneni.wordpress.com/2010/08/09/java-servlet-specification-3-0-overview-and-quick-intro/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 17:59:00 +0000</pubDate>
		<dc:creator>tejakantamneni</dc:creator>
				<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tejakantamneni.wordpress.com/2010/08/09/java-servlet-specification-3-0-overview-and-quick-intro</guid>
		<description><![CDATA[Java Servlet Technology which is the widely accepted technology for creating dynamic java web applications and which is behind all the modern java web frameworks. This major release tries to address the most wanted featues from the community as a JSR and is approved in the form of JSR 315 and is planned to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=12&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Java Servlet Technology which is the widely accepted technology for creating dynamic java web applications and which is behind all the modern java web frameworks. This major release tries to address the most wanted featues from the community as a JSR and is approved in the form of <a href="http://jcp.org/en/jsr/detail?id=315">JSR 315</a> and is planned to be part of JEE6 (<a href="http://jcp.org/en/jsr/detail?id=316">JSR 316</a>). The main focus for this release in helping in ease of developemnt using Java annotations, Pluggability and extendability of using fragments, Asynchoronos Servlet support and security enhancements.</p>
<h3>Ease of Development</h3>
<p>Using annoations Servlets join the band wagon of using declarative-style programming along with JPA, EJB3, Spring and the rest. This helpa developing Servlets, Filters more easily with the code and the related configuration in the same place and thus making the web.xml an optional. It&#8217;s the Servlet 3.0 supported contianer which will process all the classes at boot time to find out all the annotated servlets, filters and listener classes and made them available for serving. If you don&#8217;t want the container to process all the class files to figure out the annotated classes, you can turn it off using the new web.xml configuration parameter metadata-complete on web-app element to true. The other important addition which helps in ease of development and configuration is programmatic setup of serlvets and filters.</p>
<p><em>The new sample web.xml configuration</em></p>
<p><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;line-height:18px;font-size:12px;white-space:pre;"><span class="code3">1: </span><span class="code4">&lt;web-app </span><span class="code5">xmlns</span><span class="code6">=&#8221;http://java.sun.com/xml/ns/javaee&#8221; </span><span class="code5">xsi</span><span class="code6">=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221; </span><span class="code5">schemalocation</span><span class="code6">=&#8221;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&#8221; </span><span class="code5">version</span><span class="code6">=&#8221;3.0&#8243;</span><span class="code4">&gt;</span></span></p>
<div class="code0">
<pre class="code2"><span class="code3">2:  </span> <span class="code4">&lt;display-name&gt;</span><span class="code7">Sample Web Application to test Servlet </span><span class="code8">3.0 </span><span class="code4">&lt;/display-name&gt;</span></pre>
<pre class="code1"><span class="code3">3:  </span><span class="code4">&lt;/web-app&gt;</span></pre>
</div>
<p><a href="http://download.oracle.com/javaee/6/api/javax/servlet/annotation/WebServlet.html">@WebServlet</a> and <a href="http://download.oracle.com/javaee/6/api/javax/servlet/annotation/WebFilter.html">@WebFilter</a> are the two main annotations for configuring the servlets and filters in Servlet 3.0.</p>
<p>The urlPatterns attribute of the @WebServlet annotation qualifies the URL&#8217;s for this servlets to respond.</p>
<p><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;line-height:18px;font-size:12px;white-space:pre;"><span class="code3">1: </span><span class="code4">@WebServlet</span><span class="code5">(</span><span class="code6">name = </span><span class="code7">&#8220;helloServlet&#8221;</span><span class="code5">, </span><span class="code6">urlPatterns = </span><span class="code5">{</span><span class="code7">&#8220;/hello&#8221;</span><span class="code5">})</span></span></p>
<div class="code0">
<pre class="code2"><span class="code3">2:  </span><span class="code8">public </span><span class="code9">class </span><span class="code6">HelloServlet </span><span class="code10">extends </span><span class="code6">HttpServlet </span><span class="code5">{</span></pre>
<pre class="code1"><span class="code3">3:  </span></pre>
<pre class="code2"><span class="code3">4:  </span><span class="code8">protected </span><span class="code9">void </span><span class="code4">doGet</span><span class="code5">(</span><span class="code6">HttpServletRequest request</span><span class="code5">, </span><span class="code6">HttpServletResponse response</span><span class="code5">) </span><span class="code10">throws </span><span class="code6">ServletException</span><span class="code5">, </span><span class="code6">IOException </span><span class="code5">{</span></pre>
<pre class="code1"><span class="code3">5:  </span> <span class="code6">PrintWriter writer = response</span><span class="code5">.</span><span class="code4">getWriter</span><span class="code5">()</span><span class="code6">;</span></pre>
<pre class="code2"><span class="code3">6:  </span> <span class="code6">writer</span><span class="code5">.</span><span class="code4">print</span><span class="code5">(</span><span class="code7">"&lt;h1&gt;HttpServlet using Servlet 3.0&lt;/h1&gt;"</span><span class="code5">)</span><span class="code6">;</span></pre>
<pre class="code1"><span class="code3">7:  </span></pre>
<pre class="code2"><span class="code3">8:  </span><span class="code5">}</span></pre>
<pre class="code1"><span class="code3">9:  </span><span class="code5">}</span></pre>
</div>
<p>Note that the class still needs to extends HttpServlet (It is a mandatory requirement)<br />
Servlet filters and Listeners follow the same pattern except that the class needs to implement Filter and ServletContextListener classes and the annoation @WebFilter, @WebListener respectively</p>
<h3>Asynchronous Support</h3>
<p>Asynchronous Http Request Processing (aka Comet) is a way that allows you to process a single Http Request using non-blocking I/O. More details about Coment and Asynchronous programming here(http://en.wikipedia.org/wiki/Comet_%28programming%29). Basically all this means is your servlet can continue working on the request while waiting for some other resource to be released or some other operation to be done like a database update.<br />
To enable async support for your servlet, you can enable it using asyncSupported attribute of @WebServlet to true. Enabling this will give you support for few new methods in the Servletrequest itself inclluding startAsync(servletRequest, servletResponse), startAsync(), and getAsyncContext(). Once async attribute is set on the Servlet class you should either call startAsync(servletRequest, servletResponse) or startAsync() method to make an asynchronous request.</p>
<p><em> </em></p>
<p><em> </em></p>
<p><em>A simple example:<br />
<span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-style:normal;line-height:18px;font-size:12px;white-space:pre;"><span class="code3"> 1: </span><span class="code4">@WebServlet</span><span class="code5">(</span><span class="code6">&#8220;/foo&#8221; </span><span class="code7">asyncSupported=</span><span class="code8">true</span><span class="code5">)</span></span></em></p>
<div class="code0">
<pre class="code2"><span class="code3"> 2:  </span><span class="code9">public </span><span class="code10">class </span><span class="code7">MyServlet </span><span class="code11">extends </span><span class="code7">HttpServlet </span><span class="code5">{</span></pre>
<pre class="code1"><span class="code3"> 3:  </span> <span class="code9">public </span><span class="code10">void </span><span class="code4">doGet</span><span class="code5">(</span><span class="code7">HttpServletRequest req</span><span class="code5">, </span><span class="code7">HttpServletResponse res</span><span class="code5">) {</span></pre>
<pre class="code2"><span class="code3"> 4:  </span>     <span class="code7">AsyncContext aCtx = request</span><span class="code5">.</span><span class="code4">startAsync</span><span class="code5">(</span><span class="code7">req</span><span class="code5">, </span><span class="code7">res</span><span class="code5">)</span><span class="code7">;</span></pre>
<pre class="code1"><span class="code3"> 5:  </span>     <span class="code7">ScheduledThreadPoolExecutor executor = </span><span class="code8">new </span><span class="code4">ThreadPoolExecutor</span><span class="code5">(</span><span class="code12">10</span><span class="code5">)</span><span class="code7">;</span></pre>
<pre class="code2"><span class="code3"> 6:  </span>     <span class="code7">executor</span><span class="code5">.</span><span class="code4">execute</span><span class="code5">(</span><span class="code8">new </span><span class="code4">AsyncWebService</span><span class="code5">(</span><span class="code7">aCtx</span><span class="code5">))</span><span class="code7">;</span></pre>
<pre class="code1"><span class="code3"> 7:  </span> <span class="code5">}</span></pre>
<pre class="code2"><span class="code3"> 8:  </span><span class="code5">}</span></pre>
<pre class="code1"><span class="code3"> 9:  </span></pre>
<pre class="code2"><span class="code3">10:  </span><span class="code9">public </span><span class="code10">class </span><span class="code7">AsyncWebService </span><span class="code11">implements </span><span class="code7">Runnable </span><span class="code5">{</span></pre>
<pre class="code1"><span class="code3">11:  </span> <span class="code7">AsyncContext ctx;</span></pre>
<pre class="code2"><span class="code3">12:  </span> <span class="code9">public </span><span class="code4">AsyncWebService</span><span class="code5">(</span><span class="code7">AsyncContext ctx</span><span class="code5">) {</span></pre>
<pre class="code1"><span class="code3">13:  </span>     <span class="code13">this</span><span class="code5">.</span><span class="code7">ctx = ctx;</span></pre>
<pre class="code2"><span class="code3">14:  </span> <span class="code5">}</span></pre>
<pre class="code1"><span class="code3">15:  </span> <span class="code9">public </span><span class="code10">void </span><span class="code4">run</span><span class="code5">() {</span></pre>
<pre class="code2"><span class="code3">16:  </span>     <span class="code14">// Invoke web service and save result in request attribute</span></pre>
<pre class="code1"><span class="code3">17:  </span>     <span class="code14">// Dispatch the request to render the result to a JSP.</span></pre>
<pre class="code2"><span class="code3">18:  </span>     <span class="code7">ctx</span><span class="code5">.</span><span class="code4">dispatch</span><span class="code5">(</span><span class="code6">"/render.jsp"</span><span class="code5">)</span><span class="code7">;</span></pre>
<pre class="code1"><span class="code3">19:  </span><span class="code5">}</span></pre>
<pre class="code2"><span class="code3">20:  </span><span class="code5">}</span></pre>
</div>
<p>More detailed tutorial on writing Asynchronous Servlets in my next entry.</p>
<h3>Pluggability</h3>
<p>A new notion called web fragments has been introduced in servlet 3.0 specification which helps reduce the configuration. A webfragment is a part or all of web.xml configuration that can be specified by any framework or a jar file dropped into the web application. In this way the framework can by default configure itself to work with the application with out the application developer confioguring it.</p>
<p><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;line-height:18px;font-size:12px;white-space:pre;"><span class="code3"> 1: </span><span class="code4">&lt;web-fragment&gt;</span></span></p>
<div class="code0">
<pre class="code2"><span class="code3"> 2:  </span><span class="code4">&lt;servlet&gt;</span></pre>
<pre class="code1"><span class="code3"> 3:  </span><span class="code4">&lt;description&gt;&lt;/description&gt;</span></pre>
<pre class="code2"><span class="code3"> 4:  </span><span class="code4">&lt;display-name&gt;</span><span class="code5">TestServlet</span><span class="code4">&lt;/display-name&gt;</span></pre>
<pre class="code1"><span class="code3"> 5:  </span><span class="code4">&lt;servlet-name&gt;</span><span class="code5">TestServlet</span><span class="code4">&lt;/servlet-name&gt;</span></pre>
<pre class="code2"><span class="code3"> 6:  </span><span class="code4">&lt;servlet-class&gt;</span><span class="code5">sample.TestServlet</span><span class="code4">&lt;/servlet-class&gt;</span></pre>
<pre class="code1"><span class="code3"> 7:  </span><span class="code4">&lt;/servlet&gt;</span></pre>
<pre class="code2"><span class="code3"> 8:  </span><span class="code4">&lt;servlet-mapping&gt;</span></pre>
<pre class="code1"><span class="code3"> 9:  </span><span class="code4">&lt;servlet-name&gt;</span><span class="code5">TestServlet</span><span class="code4">&lt;/servlet-name&gt;</span></pre>
<pre class="code2"><span class="code3">10:  </span><span class="code4">&lt;url-pattern&gt;</span><span class="code5">/TestServlet</span><span class="code4">&lt;/url-pattern&gt;</span></pre>
<pre class="code1"><span class="code3">11:  </span><span class="code4">&lt;/servlet-mapping&gt;</span></pre>
<pre class="code2"><span class="code3">12:  </span><span class="code4">&lt;/web-fragment&gt;</span></pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tejakantamneni.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tejakantamneni.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tejakantamneni.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tejakantamneni.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tejakantamneni.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tejakantamneni.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tejakantamneni.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tejakantamneni.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tejakantamneni.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tejakantamneni.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tejakantamneni.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tejakantamneni.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tejakantamneni.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tejakantamneni.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=12&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tejakantamneni.wordpress.com/2010/08/09/java-servlet-specification-3-0-overview-and-quick-intro/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d555c04f1b80fbe575c122979fd25e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tejakantamneni</media:title>
		</media:content>
	</item>
		<item>
		<title>Partial mocking of objects using easymock classextensions</title>
		<link>http://tejakantamneni.wordpress.com/2008/09/11/partial-mocking-of-objects-using-easymock-classextensions/</link>
		<comments>http://tejakantamneni.wordpress.com/2008/09/11/partial-mocking-of-objects-using-easymock-classextensions/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 23:34:00 +0000</pubDate>
		<dc:creator>tejakantamneni</dc:creator>
				<category><![CDATA[easymock]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://tejakantamneni.wordpress.com/2008/09/11/partial-mocking-of-objects-using-easymock-classextensions/</guid>
		<description><![CDATA[Ocassionally, some of your methods in your classes need to call some other public methods in the same class to get the job done. But when writing unit tests for the calling methods, you want to keep your tests isolated from the calls to other public methods. I encountered such a scenario recently and found [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=7&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ocassionally, some of your methods in your classes need to call some other public methods in the same class to get the job done. But when writing unit tests for the calling methods, you want to keep your tests isolated from the calls to other public methods. I encountered such a scenario recently and found that Easymock can help you by mocking some of the methods while keeping the rest of the methods intact.</p>
<p>Let us see an example,<br />
The BlogSearchService has two public methods, first method filterBlogsByAuthor takes an author name and a list of blogs and returns all the blogs written by that particular order author.<br />
The other business method searchBlogs will take a search paramter and the author, it will get all the blogs by the search parameter using a custom logic and do some other house keeping tasks like sorting them by published date and number of comments and then filter the methods by author.</p>
<pre style="width:500px;font-family:courier new;font-size:12px;padding:0 0 20px;"><span style="color:blue;">package</span> com.teja.blogs;

<span style="color:blue;">import</span> <span style="color:olive;">java</span>.<span style="color:olive;">util</span>.<span style="color:olive;">Collections</span>;<span style="color:blue;">import</span> <span style="color:olive;">java</span>.<span style="color:olive;">util</span>.<span style="color:olive;">List</span>;

<span style="color:green;">/**** @author Teja*/</span><span style="color:blue;">public</span> <span style="color:blue;">class</span> BlogSearchService {

      <span style="color:blue;">public</span> <span style="color:olive;">List</span>&lt;Blog&gt; searchBlogs(<span style="color:olive;">String</span> searchString, <span style="color:olive;">String</span> author){

              <span style="color:green;">//do some custom logic here on these blogs like sorting them by posted date.</span>              <span style="color:blue;">return</span> filterBlogsByAuthor(author, <span style="color:olive;">Collections</span>.EMPTY_LIST);      }

      <span style="color:blue;">public</span> <span style="color:olive;">List</span>&lt;Blog&gt; filterBlogsByAuthor(<span style="color:olive;">String</span> author, <span style="color:olive;">List</span>&lt;Blog&gt; blogs){
             <span style="color:blue;">return</span> <span style="color:olive;">Collections</span>.EMPTY_LIST;
 }

}</pre>
<p>When writing the test cases for the second method, I don&#8217;t want to test the other public method filterByAuthor as<br />
(i)it has already been tested by other test cases,<br />
(ii)I want to keep my test cases more unit.</p>
<p>So in my test case where I am testing my searchBlogs, I am creating the mock service class which has mock methods only for filterBlogsByAuthor, but the actual mehtod(searchBlogs) which is about to be tested is not.<br />
As usual you can do expectations on the mock class, replay and verify as if it is some other external resource being mocked.</p>
<p>To create a partial mock class of the service, the extra parameter you need to pass is the name of the method to be mocked and the parameter types it accepts (coz, it need to know which version of the  method you want to mock if you have overloaded methods)</p>
<p>Here is our test class:</p>
<pre style="overflow:auto;width:500px;font-family:courier new;font-size:12px;padding:0 0 20px;"><span style="color:blue;">package</span> com.teja.blogs;

<span style="color:blue;">import</span> <span style="color:olive;">java</span>.<span style="color:olive;">util</span>.<span style="color:olive;">Collections</span>;<span style="color:blue;">import</span> <span style="color:olive;">java</span>.<span style="color:olive;">util</span>.<span style="color:olive;">List</span>;<span style="color:blue;">import</span> <span style="color:olive;">org</span>.junit.Test;<span style="color:blue;">import</span> <span style="color:olive;">org</span>.easymock.classextension.EasyMock;

<span style="color:green;">/**** @author Teja*/</span><span style="color:blue;">public</span> <span style="color:blue;">class</span> BlogSearchServiceTest {

        @Test        <span style="color:blue;">
public</span> <span style="color:blue;">void</span> testSearchBlogs() <span style="color:blue;">throws</span> <span style="color:olive;">NoSuchMethodException</span> {
 <span style="color:olive;">String</span> author = "<span style="color:magenta;">Teja</span>";
BlogSearchService blogSearchService =
EasyMock.createMock(BlogSearchService.<span style="color:blue;">class</span>,BlogSearchService.<span style="color:blue;">class</span>.getMethod("<span style="color:magenta;">filterBlogsByAuthor</span>", <span style="color:blue;">
new</span> <span style="color:olive;">Class</span>[]{<span style="color:olive;">String</span>.<span style="color:blue;">class</span>, <span style="color:olive;">List</span>.<span style="color:blue;">class</span>}));
EasyMock.expect(blogSearchService.filterBlogsByAuthor(author, <span style="color:olive;">Collections</span>.EMPTY_LIST)).andReturn(<span style="color:olive;">Collections</span>.EMPTY_LIST);                EasyMock.replay(blogSearchService);                blogSearchService.searchBlogs("<span style="color:magenta;">easymock</span>", author);                EasyMock.verify(blogSearchService);        }

}</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tejakantamneni.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tejakantamneni.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tejakantamneni.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tejakantamneni.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tejakantamneni.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tejakantamneni.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tejakantamneni.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tejakantamneni.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tejakantamneni.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tejakantamneni.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tejakantamneni.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tejakantamneni.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tejakantamneni.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tejakantamneni.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tejakantamneni.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tejakantamneni.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=7&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tejakantamneni.wordpress.com/2008/09/11/partial-mocking-of-objects-using-easymock-classextensions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d555c04f1b80fbe575c122979fd25e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tejakantamneni</media:title>
		</media:content>
	</item>
		<item>
		<title>Pagination in rails using will_paginate</title>
		<link>http://tejakantamneni.wordpress.com/2008/09/06/pagination-in-rails-using-will_paginate/</link>
		<comments>http://tejakantamneni.wordpress.com/2008/09/06/pagination-in-rails-using-will_paginate/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 15:06:00 +0000</pubDate>
		<dc:creator>tejakantamneni</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[will_paginate]]></category>

		<guid isPermaLink="false">http://tejakantamneni.wordpress.com/2008/09/06/pagination-in-rails-using-will_paginate/</guid>
		<description><![CDATA[Pagination is a technique of presenting large amount of data on the UI, allowing the users to navigate between pages/data in an easy way.Being a java developer for so many years, I remember doing dirty logic to achieve pagination to using some very useful and advanced tag libraries like displaytag. What ever may be the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=6&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Pagination">Pagination</a> is a technique of presenting large amount of data on the UI, allowing the users to navigate between pages/data in an easy way.<br />Being a java developer for so many years, I remember doing dirty logic to achieve pagination to using some very useful and advanced tag libraries like <a href="http://displaytag.sourceforge.net/11/">displaytag</a>. What ever may be the technique, pagination is never been an easy task.<br />But when I started playing around with rails and I got a situation where I need to do some pagination. And I readily found a gem will_paginate and doing pagination on rails is a breeze.</p>
<p>Lets get started first by installing the gem.<br />
<table class="CodeRay">
<tbody>
<tr>
<td class="line_numbers">
<pre><tt></tt></pre>
</td>
<p>
<td class="code">
<pre>sudo gem install will_paginate</pre>
</td>
</tr>
</tbody>
</table>
<p>To check whether the plugin installed successfully or not, you can do the following in your rails console.<br />
<table class="CodeRay">
<tbody>
<tr>
<td class="line_numbers">
<pre>1<tt></tt>2<tt></tt>3<tt></tt></pre>
</td>
<p>
<td class="code">
<pre><span class="r">defined?</span> <span class="co">WillPaginate</span><tt></tt>[].paginate<tt></tt><span class="co">ActiveRecord</span>::<span class="co">Base</span>.respond_to? <span class="sy">:paginate</span></pre>
</td>
<p></tr>
</tbody>
</table>
<p>Now lets add pagination support to an imaginary page listing all the clients<br />
<table class="CodeRay">
<tbody>
<tr>
<td class="line_numbers">
<pre>1<tt></tt>2<tt></tt>3<tt></tt></pre>
</td>
<p>
<td class="code">
<pre>  <span class="r">def</span> <span class="fu">list_clients</span><tt></tt>    <span class="iv">@clients</span> = <span class="co">Client</span>.paginate(<span class="sy">:page</span> =&gt; params[<span class="sy">:page</span>], <span class="sy">:per_page</span> =&gt; <span class="i">5</span>)<tt></tt>  <span class="r">end</span></pre>
</td>
<p></tr>
</tbody>
</table>
<p>and then render the pagination in the ui using this simple snippet<br />
<table class="CodeRay">
<tbody>
<tr>
<td class="line_numbers">
<pre>1<tt></tt>2<tt></tt>3<tt></tt>4<tt></tt>5<tt></tt>6<tt></tt>7<tt></tt>8<tt></tt>9<tt></tt><strong>10</strong><tt></tt>11<tt></tt>12<tt></tt>13<tt></tt>14<tt></tt>15<tt></tt></pre>
</td>
<p>
<td class="code">
<pre>&lt;h3&gt;<span class="co">Clients</span>&lt;<span class="rx"><span class="dl">/</span><span class="k">h3&gt;<tt></tt><tt></tt>&lt;%= will_paginate @clients %&gt;<tt></tt>&lt;!--Loop through all the clients and printem--&gt;<tt></tt>&lt;table width=100% cellpadding=0 cellspacing=0 border=0&gt;<tt></tt>        &lt;% for @client in @clients do%&gt;<tt></tt>        &lt;tr class='client_details'&gt;<tt></tt>                &lt;td align='center'&gt;&lt;%=@client.client_name.upcase%&gt;&lt;</span><span class="dl">/</span></span>td&gt;<tt></tt>                &lt;td&gt;<tt></tt>                        &lt;<span class="s"><span class="dl">%=</span><span class="k">@client.address_line_1%&gt;,&lt;%</span><span class="dl">=</span></span><span class="iv">@client</span>.address_line_2%&gt;&lt;br <span class="rx"><span class="dl">/</span><span class="k">&gt;<tt></tt>                        &lt;%=@client.city%&gt;,&lt;%=@client.state%&gt;,&lt;%=@client.zip%&gt;<tt></tt>                &lt;</span><span class="dl">/</span></span>td&gt;<tt></tt>        &lt;<span class="rx"><span class="dl">/</span><span class="k">tr&gt;<tt></tt>        &lt;%end%&gt;<tt></tt>&lt;</span><span class="dl">/</span></span>table&gt;</pre>
</td>
<p></tr>
</tbody>
</table>
<p>The code  will add the links to previous/next page along with the page numbers to naviage.<br />The next few lines of code is just to print the client details.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tejakantamneni.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tejakantamneni.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tejakantamneni.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tejakantamneni.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tejakantamneni.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tejakantamneni.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tejakantamneni.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tejakantamneni.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tejakantamneni.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tejakantamneni.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tejakantamneni.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tejakantamneni.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tejakantamneni.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tejakantamneni.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tejakantamneni.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tejakantamneni.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=6&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tejakantamneni.wordpress.com/2008/09/06/pagination-in-rails-using-will_paginate/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d555c04f1b80fbe575c122979fd25e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tejakantamneni</media:title>
		</media:content>
	</item>
		<item>
		<title>Developing web services using Spring ws and JAXB marshaller</title>
		<link>http://tejakantamneni.wordpress.com/2008/08/25/developing-web-services-using-spring-ws-and-jaxb-marshaller/</link>
		<comments>http://tejakantamneni.wordpress.com/2008/08/25/developing-web-services-using-spring-ws-and-jaxb-marshaller/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 23:31:00 +0000</pubDate>
		<dc:creator>tejakantamneni</dc:creator>
				<category><![CDATA[jaxb]]></category>
		<category><![CDATA[marshaller]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring web services]]></category>
		<category><![CDATA[spring ws]]></category>
		<category><![CDATA[springframework]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://tejakantamneni.wordpress.com/2008/08/25/developing-web-services-using-spring-ws-and-jaxb-marshaller/</guid>
		<description><![CDATA[Spring web services a product of spring community, helps in developing web services using contract first web services and helps in manipulating the xml in many ways. In this tutorial I am about to show a step by step guide in developing spring web services using JAXB as mashalling technology. You can download spring, spring [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=5&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Spring web services a product of spring community, helps in developing web services using contract first web services and helps in manipulating the xml in many ways. In this tutorial I am about to show a step by step guide in developing spring web services using JAXB as mashalling technology.</p>
<p>You can download spring, spring web services <a href="http://springframework.org/download">here</a>.</p>
<p>We are about to develop a web service which search the blogs based on a search criteria on title string and published date.</p>
<p>So lets get started,</p>
<p>1.Create a web application<br />This is a general spring web MVC application. for a skeleton application, you can just run this maven archetype to quickly start with,</p>
<p>mvn archetype:create -DarchetypeGroupId=org.springframework.ws \<br />-DarchetypeArtifactId=spring-ws-archetype \<br />-DarchetypeVersion=1.5.4 \<br />-DgroupId=com.teja \<br />-DartifactId=spring-ws-test</p>
<p>Or you can just add the spring nature to your existing web application by configuring the web.xml shown in the next step. Here is the file structure I am using for this simple demo.</p>
<p><img src="http://farm4.static.flickr.com/3116/2797531373_3617233f61.jpg" /></p>
<p>2.Configure web.xml.
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">   <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>spring-ws<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">   <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-class<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>org.springframework.ws.transport.http.MessageDispatcherServlet<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-class<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>spring-ws<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>/*<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>spring-ws<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>*.wsdl<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>spring-ws<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>*.soap<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/servlet-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p></ol>
</div>
<p>Spring strongly supports only contract first web services for several reasons like Fragility, performance, re usability and versioning.<br />You can find more information visit this <a href="http://static.springframework.org/spring-ws/sites/1.5/reference/html/why-contract-first.html">link</a></p>
<p>So lets start first by developing our  XSD&#8230;.
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;?xml</span> <span style="color:rgb(0, 0, 102);">version</span>=<span style="color:rgb(255, 0, 0);">&#8220;1.0&#8243;</span> <span style="color:rgb(0, 0, 102);">encoding</span>=<span style="color:rgb(255, 0, 0);">&#8220;UTF-8&#8243;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">?&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:schema</span> <span style="color:rgb(0, 0, 102);">xmlns:xsd</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.w3.org/2001/XMLSchema&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">targetNamespace</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/schemas&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns:tns</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/schemas&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">elementFormDefault</span>=<span style="color:rgb(255, 0, 0);">&#8220;qualified&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:schema<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p></ol>
</div>
<p>This is a plain regular xsd where we will define all our xml elements going to create our wsdl file.<br />Lets define our blog object, the blog is just a complex type object with three properties the &#8220;Title&#8221; for the blog, the &#8220;AbstractDetail&#8221; of the blog and the date when the blog is published &#8220;PublishedDate&#8221;. This can be defined in the xml complex type<br />as follows&#8230;</p>
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:complexType</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;Blog&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">  <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">      <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;Title&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;xsd:string&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">      <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;AbstractDetail&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;xsd:string&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">      <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;PublishedDate&#8221;</span> type =<span style="color:rgb(255, 0, 0);">&#8220;xsd:dateTime&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">  <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p></ol>
</div>
<p>Next step is defining the search criteria object, I am wrapping the search criteria into a seperate object so that in future, we can extend the search criteria by adding more elements like author, subject. Here the xsd definition of the search criteria<br />object with two fields title and published date.</p>
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;SearchCriteria&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;Title&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;xsd:string&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;PublishedDate&#8221;</span> type =<span style="color:rgb(255, 0, 0);">&#8220;xsd:dateTime&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:element<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>  </div>
</li>
<p></ol>
</div>
<p>The next stepa are creating the actual request object for our web service, which is basically a wrapper on the search criteria and our response object which is just a array/list of blog objects (which can be either zero size, if search results nothing<br />or can be of size n if search returns n objects).<br />Here is our completed xsd,
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;?xml</span> <span style="color:rgb(0, 0, 102);">version</span>=<span style="color:rgb(255, 0, 0);">&#8220;1.0&#8243;</span> <span style="color:rgb(0, 0, 102);">encoding</span>=<span style="color:rgb(255, 0, 0);">&#8220;UTF-8&#8243;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">?&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:schema</span> <span style="color:rgb(0, 0, 102);">xmlns:xsd</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.w3.org/2001/XMLSchema&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">targetNamespace</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/schemas&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns:tns</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/schemas&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">elementFormDefault</span>=<span style="color:rgb(255, 0, 0);">&#8220;qualified&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchRequest&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">ref</span>=<span style="color:rgb(255, 0, 0);">&#8220;tns:SearchCriteria&#8221;</span> <span style="color:rgb(0, 0, 102);">minOccurs</span>=<span style="color:rgb(255, 0, 0);">&#8220;0&#8243;</span> maxOccurs = <span style="color:rgb(255, 0, 0);">&#8220;unbounded&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:element<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchResponse&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;blogList&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;tns:Blog&#8221;</span> <span style="color:rgb(0, 0, 102);">minOccurs</span>=<span style="color:rgb(255, 0, 0);">&#8220;0&#8243;</span> maxOccurs = <span style="color:rgb(255, 0, 0);">&#8220;unbounded&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:element<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;SearchCriteria&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;Title&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;xsd:string&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;PublishedDate&#8221;</span> type =<span style="color:rgb(255, 0, 0);">&#8220;xsd:dateTime&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:element<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:complexType</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;Blog&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;Title&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;xsd:string&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;AbstractDetail&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;xsd:string&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:element</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;PublishedDate&#8221;</span> type =<span style="color:rgb(255, 0, 0);">&#8220;xsd:dateTime&#8221;</span> <span style="color:rgb(0, 0, 102);">nillable</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:sequence<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:complexType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:schema<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p></ol>
</div>
<p>The next in developing our web services is defining our contract, the WSDL file.<br />Here is the complete version the WSDL file.<br />Essentilly we are improting the xsd file which we had created in the earlier step to use them in the wsdl<br />Then create the message parts, the port and the binding operation for the blog search service. This is self explanatory.
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;?xml</span> <span style="color:rgb(0, 0, 102);">version</span>=<span style="color:rgb(255, 0, 0);">&#8220;1.0&#8243;</span> <span style="color:rgb(0, 0, 102);">encoding</span>=<span style="color:rgb(255, 0, 0);">&#8220;UTF-8&#8243;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">?&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;definitions</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearch&#8221;</span> <span style="color:rgb(0, 0, 102);">targetNamespace</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/definitions&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://schemas.xmlsoap.org/wsdl/&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns:soap</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://schemas.xmlsoap.org/wsdl/soap/&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns:wsdl</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://schemas.xmlsoap.org/wsdl/&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns:xsd</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.w3.org/2001/XMLSchema&#8221;</span> </span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns:tns</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/definitions&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">    <span style="color:rgb(0, 0, 102);">xmlns:schema</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/schemas&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:types<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:schema</span> <span style="color:rgb(0, 0, 102);">targetNamespace</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/definitions&#8221;</span> <span style="color:rgb(0, 0, 102);">xmlns:schema</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/schemas&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;xsd:import</span> <span style="color:rgb(0, 0, 102);">namespace</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://com.tejakantamneni/schemas&#8221;</span> <span style="color:rgb(0, 0, 102);">schemaLocation</span>=<span style="color:rgb(255, 0, 0);">&#8220;../schemas/BlogSearch.xsd&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/xsd:schema<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:types<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:message</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchRequest&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:part</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchRequest&#8221;</span> <span style="color:rgb(0, 0, 102);">element</span>=<span style="color:rgb(255, 0, 0);">&#8220;schema:BlogSearchRequest&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:message<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:message</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchResponse&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:part</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchResponse&#8221;</span> <span style="color:rgb(0, 0, 102);">element</span>=<span style="color:rgb(255, 0, 0);">&#8220;schema:BlogSearchResponse&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:message<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:portType</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchService&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:operation</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchOperation&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:input</span> <span style="color:rgb(0, 0, 102);">message</span>=<span style="color:rgb(255, 0, 0);">&#8220;tns:BlogSearchRequest&#8221;</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchRequest&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:output</span> <span style="color:rgb(0, 0, 102);">message</span>=<span style="color:rgb(255, 0, 0);">&#8220;tns:BlogSearchResponse&#8221;</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchResponse&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:operation<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:portType<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:binding</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchBinding&#8221;</span> <span style="color:rgb(0, 0, 102);">type</span>=<span style="color:rgb(255, 0, 0);">&#8220;tns:BlogSearchService&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;soap:binding</span> <span style="color:rgb(0, 0, 102);">style</span>=<span style="color:rgb(255, 0, 0);">&#8220;document&#8221;</span> <span style="color:rgb(0, 0, 102);">transport</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://schemas.xmlsoap.org/soap/http&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:operation</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchOperation&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;soap:operation</span> <span style="color:rgb(0, 0, 102);">soapAction</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://tejakantamneni.com/SearchBlogs&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:input</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchRequest&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;soap:body</span> <span style="color:rgb(0, 0, 102);">use</span>=<span style="color:rgb(255, 0, 0);">&#8220;literal&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:input<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:output</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchResponse&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;soap:body</span> <span style="color:rgb(0, 0, 102);">use</span>=<span style="color:rgb(255, 0, 0);">&#8220;literal&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:output<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:operation<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:binding<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">     <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:service</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchService&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;wsdl:port</span> <span style="color:rgb(0, 0, 102);">binding</span>=<span style="color:rgb(255, 0, 0);">&#8220;tns:BlogSearchBinding&#8221;</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearchBindingPort&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;soap:address</span> <span style="color:rgb(0, 0, 102);">location</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://localhost:8080/spring-ws-test/BlogSearch.soap&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:port<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/wsdl:service<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/definitions<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p></ol>
</div>
<p>next step is creating the JAXB objects for your xsd elements using xjc compiler. you can either craft the JAXB objects by hand or just<br />use the xjc compiler. I prefer the later one. see https://jaxb.dev.java.net/guide/ for more details. (My Intellij Idea supports generating JAXB objects directly from xsd).</p>
<p>(Posting all the code is not practical, So I am moving here ahead posting the important parts)<br />Here is the endpoint
<div class="java5 java5" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;">/*</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> * To change this template, choose Tools | Templates</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> * and open the template in the editor.</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> */</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">package</span> <span style="color:rgb(0, 102, 153);">com.teja.service.endpoint</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">com.teja.Blog</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">com.teja.BlogSearchRequest</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">com.teja.BlogSearchResponse</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">com.teja.SearchCriteria</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">java.util.ArrayList</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">java.util.Date</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">java.util.GregorianCalendar</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">java.util.List</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">javax.xml.datatype.DatatypeConfigurationException</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">javax.xml.datatype.DatatypeFactory</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">javax.xml.datatype.XMLGregorianCalendar</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">javax.xml.transform.Source</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.beans.factory.annotation.Autowired</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.oxm.Marshaller</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.oxm.support.MarshallingSource</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.ws.server.endpoint.annotation.Endpoint</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.ws.server.endpoint.annotation.XPathParam</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.ws.soap.server.endpoint.annotation.SoapAction</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;">/**</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> * @author Teja Kantamneni </span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> * @version 1.0 Aug 25, 2008 &#8211; 11:30:49 AM</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> */</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">@Endpoint</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">class</span> BlogSearchEndpoint <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    </div>
<p></li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">static</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">final</span> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">String</span></a> BLOG_SEARCH_ACTION = <span style="color:rgb(0, 0, 255);">&#8220;http://tejakantamneni.com/SearchBlogs&#8221;</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    @Autowired</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    Marshaller marshaller;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    @SoapAction<span style="color:rgb(0, 153, 0);">(</span>BLOG_SEARCH_ACTION<span style="color:rgb(0, 153, 0);">)</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">   <span style="color:rgb(102, 102, 102);font-style:italic;">// public Source searchBlogs(@XPathParam(&#8220;/sch:BlogSearchRequest/sch:SearchCriteria/sch:Title&#8221;) String title, @XPathParam(&#8220;/sch:BlogSearchRequest/sch:SearchCriteria/sch:PublishedDate&#8221;) String publishedDate) throws DatatypeConfigurationException {</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">     <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> BlogSearchResponse searchBlogs<span style="color:rgb(0, 153, 0);">(</span>BlogSearchRequest blogSearchRequest<span style="color:rgb(0, 153, 0);">)</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">throws</span> <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/DatatypeConfigurationException.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">DatatypeConfigurationException</span></a> <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        BlogSearchResponse blogSearchResponse = <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> BlogSearchResponse<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        List<span style="color:rgb(51, 153, 51);">&lt;</span>Blog<span style="color:rgb(51, 153, 51);">&gt;</span> resultBlogs = <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> ArrayList<span style="color:rgb(51, 153, 51);">&lt;</span>Blog<span style="color:rgb(51, 153, 51);">&gt;</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        </div>
<p></li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/DatatypeFactory.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">DatatypeFactory</span></a> datatypeFactory = <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/DatatypeFactory.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">DatatypeFactory</span></a>.<span style="color:rgb(0, 102, 51);">newInstance</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/GregorianCalendar.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">GregorianCalendar</span></a> gregorianCalendar = <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/GregorianCalendar.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">GregorianCalendar</span></a><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            gregorianCalendar.<span style="color:rgb(0, 102, 51);">setTime</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> <a href="http://www.google.com/search?sitesearch=java.sun.com&amp;q=allinurl%3Aj2se%2F1+5+0%2Fdocs%2Fapi+Date"><span style="color:rgb(0, 51, 153);font-weight:bold;">Date</span></a><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/XMLGregorianCalendar.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">XMLGregorianCalendar</span></a> xmlGregorianCalendar = datatypeFactory.<span style="color:rgb(0, 102, 51);">newXMLGregorianCalendar</span><span style="color:rgb(0, 153, 0);">(</span>gregorianCalendar<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            </div>
<p></li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        Blog b = <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> Blog<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        b.<span style="color:rgb(0, 102, 51);">setAbstractDetail</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 0, 255);">&#8220;Abstract details -teja&#8221;</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        b.<span style="color:rgb(0, 102, 51);">setTitle</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 0, 255);">&#8220;Teja test&#8221;</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        b.<span style="color:rgb(0, 102, 51);">setPublishedDate</span><span style="color:rgb(0, 153, 0);">(</span>xmlGregorianCalendar<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        resultBlogs.<span style="color:rgb(0, 102, 51);">add</span><span style="color:rgb(0, 153, 0);">(</span>b<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 0, 0);">for</span> <span style="color:rgb(0, 153, 0);">(</span>Blog blog : resultBlogs<span style="color:rgb(0, 153, 0);">)</span> <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">            blogSearchResponse.<span style="color:rgb(0, 102, 51);">getBlogList</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>.<span style="color:rgb(0, 102, 51);">add</span><span style="color:rgb(0, 153, 0);">(</span>blog<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 0, 0);font-weight:bold;">return</span> blogSearchResponse;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
</ol>
</div>
<p>now the last and more important step, putting all the things together to deploy the service,configuring the spring-ws-servlet.xml</p>
<p>First and the most important point here is I am autowiring the endpoint by using the annotation @Endpoint. </p>
<p>So in the context.xml, we are defining the wsdl to be exposed as a bean using the class org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition.<br />I am specifying the JAXBMarshaller and injecting all the jaxb classes.<br />I am also configuring a couple of beans for validating and logging each and every request and response.</p>
<p>
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;?xml</span> <span style="color:rgb(0, 0, 102);">version</span>=<span style="color:rgb(255, 0, 0);">&#8220;1.0&#8243;</span> <span style="color:rgb(0, 0, 102);">encoding</span>=<span style="color:rgb(255, 0, 0);">&#8220;UTF-8&#8243;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">?&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;beans</span> <span style="color:rgb(0, 0, 102);">xmlns</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.springframework.org/schema/beans&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">       <span style="color:rgb(0, 0, 102);">xmlns:xsi</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.w3.org/2001/XMLSchema-instance&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">       <span style="color:rgb(0, 0, 102);">xmlns:context</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.springframework.org/schema/context&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">       <span style="color:rgb(0, 0, 102);">xmlns:jee</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.springframework.org/schema/jee&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">       <span style="color:rgb(0, 0, 102);">xmlns:lang</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.springframework.org/schema/lang&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">       <span style="color:rgb(0, 0, 102);">xmlns:util</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.springframework.org/schema/util&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">       <span style="color:rgb(0, 0, 102);">xmlns:p</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.springframework.org/schema/p&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">       <span style="color:rgb(0, 0, 102);">xsi:schemaLocation</span>=<span style="color:rgb(255, 0, 0);">&#8220;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(255, 0, 0);">       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(255, 0, 0);">       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(255, 0, 0);">       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(255, 0, 0);">       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">id</span>=<span style="color:rgb(255, 0, 0);">&#8220;BlogSearch&#8221;</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">           <span style="color:rgb(0, 0, 102);">p:wsdl</span>=<span style="color:rgb(255, 0, 0);">&#8220;/wsdls/BlogSearch.wsdl&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;font-family:monospace;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;constructor-arg</span> <span style="color:rgb(0, 0, 102);">ref</span>=<span style="color:rgb(255, 0, 0);">&#8220;marshaller&#8221;</span> <span style="color:rgb(0, 0, 102);">index</span>=<span style="color:rgb(255, 0, 0);">&#8220;0&#8243;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">id</span>=<span style="color:rgb(255, 0, 0);">&#8220;marshaller&#8221;</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.oxm.jaxb.Jaxb2Marshaller&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;classesToBeBound&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;list<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>com.teja.Blog<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>com.teja.BlogSearchRequest<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>com.teja.BlogSearchResponse<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>com.teja.SearchCriteria<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/list<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/property<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;schema&#8221;</span> <span style="color:rgb(0, 0, 102);">value</span>=<span style="color:rgb(255, 0, 0);">&#8220;/schemas/BlogSearch.xsd&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;interceptors&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;list<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;ref</span> <span style="color:rgb(0, 0, 102);">bean</span>=<span style="color:rgb(255, 0, 0);">&#8220;validatingInterceptor&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/list<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/property<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;interceptors&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;list<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;ref</span> <span style="color:rgb(0, 0, 102);">bean</span>=<span style="color:rgb(255, 0, 0);">&#8220;validatingInterceptor&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/list<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/property<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span>   <span style="color:rgb(0, 0, 102);">id</span>=<span style="color:rgb(255, 0, 0);">&#8220;validatingInterceptor&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">            <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">            <span style="color:rgb(0, 0, 102);">p:schema</span>=<span style="color:rgb(255, 0, 0);">&#8220;/schemas/BlogSearch.xsd&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">            <span style="color:rgb(0, 0, 102);">p:validateRequest</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">            <span style="color:rgb(0, 0, 102);">p:validateResponse</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;namespaces&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;props<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;prop</span> <span style="color:rgb(0, 0, 102);">key</span>=<span style="color:rgb(255, 0, 0);">&#8220;sch&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span>http://com.tejakantamneni/schemas<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/prop<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">                <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;prop</span> <span style="color:rgb(0, 0, 102);">key</span>=<span style="color:rgb(255, 0, 0);">&#8220;xs&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span>http://www.w3.org/2001/XMLSchema<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/prop<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">            <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/props<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/property<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">     <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211; scan classes for dependency annotations &#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;context:component-scan</span> <span style="color:rgb(0, 0, 102);">base-package</span>=<span style="color:rgb(255, 0, 0);">&#8220;com.teja&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;context:annotation-config</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;order&#8221;</span> <span style="color:rgb(0, 0, 102);">value</span>=<span style="color:rgb(255, 0, 0);">&#8220;2&#8243;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/beans<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;margin:0;padding:0;"> </div>
</li>
<p></ol>
</div>
<p>you can access the wsdl at http://localhost:8080/spring-ws-test/wsdl/BlogSearch.wsdl</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tejakantamneni.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tejakantamneni.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tejakantamneni.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tejakantamneni.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tejakantamneni.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tejakantamneni.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tejakantamneni.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tejakantamneni.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tejakantamneni.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tejakantamneni.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tejakantamneni.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tejakantamneni.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tejakantamneni.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tejakantamneni.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tejakantamneni.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tejakantamneni.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=5&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tejakantamneni.wordpress.com/2008/08/25/developing-web-services-using-spring-ws-and-jaxb-marshaller/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d555c04f1b80fbe575c122979fd25e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tejakantamneni</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3116/2797531373_3617233f61.jpg" medium="image" />
	</item>
		<item>
		<title>Testing Spring applications with jUnit 4 and Easy Mock</title>
		<link>http://tejakantamneni.wordpress.com/2008/08/24/testing-spring-applications-with-junit-4-and-easy-mock/</link>
		<comments>http://tejakantamneni.wordpress.com/2008/08/24/testing-spring-applications-with-junit-4-and-easy-mock/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 03:53:00 +0000</pubDate>
		<dc:creator>tejakantamneni</dc:creator>
				<category><![CDATA[easymock]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://tejakantamneni.wordpress.com/2008/08/24/testing-spring-applications-with-junit-4-and-easy-mock/</guid>
		<description><![CDATA[Unit tests help us make sure that the unit chunks of code being developed are correct. Unit test helps find bugs in the early stages of software development. Java unit testing frameworks like jUnit, TestNG with some other pretty frameworks like easy mock and easy mock class extensions help us test individual classes with mocking [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=4&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Unit tests help us make sure that the unit chunks of code being developed are correct. Unit test helps find bugs in the early stages of software development.</p>
<p>Java unit testing frameworks like <a href="http://www.junit.org/">jUnit</a>, <a href="http://testng.org/doc/">TestNG</a> with some other pretty frameworks like<a href="http://www.easymock.org/"> easy mock </a>and easy mock class extensions help us test individual classes with mocking out the external dependent classes/resources and make the tests more &#8220;unit&#8221;.</p>
<p>Spring out of the box supports unit testing with jUnit and TestNG. Spring provides seperate set of classes help you unit test your spring classes.</p>
<p>Spring 2.5 in its <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/test/context/package-summary.html">org.springframework.test.context</a> package has a set of classes to have better unit testing using jUnit4.</p>
<p>I am about to show an example of testing a service called BlogSearchService. The service simply calls a method in the blogDAO which searches the blogs based on the keyword and return a list of blogs. So here my service class is simple, it calls the DAO. So in my test I just have to make sure that it makes a DAO call and the result is then returned to the client.</p>
<p>Lets see the code for BlogSearchService and BlogSearchServiceImpl,</p>
<p>BlogSearchService.java
<div class="java5 java5" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">package</span> <span style="color:rgb(0, 102, 153);">com.teja.tests</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">java.util.List</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;">/**</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> *</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> * @author Teja Kantamneni</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> */</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">interface</span> BlogSearchService <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> List<span style="color:rgb(51, 153, 51);">&lt;</span>Blog<span style="color:rgb(51, 153, 51);">&gt;</span> searchBlogByKeyWord<span style="color:rgb(0, 153, 0);">(</span><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">String</span></a> keyword<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">}</span></div>
</li>
</ol>
</div>
<p>BlogSearchServiceImpl.java
<div class="java5 java5" style="border:1px solid rgb(208, 208, 208);font-family:monospace;color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">package</span> <span style="color:rgb(0, 102, 153);">com.teja.tests</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">java.util.List</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.beans.factory.annotation.Autowired</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;">/**</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> *</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> * @author Teja Kantamneni</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> */</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">class</span> BlogSearchServiceImpl <span style="color:rgb(0, 0, 0);font-weight:bold;">implements</span> BlogSearchService <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    @Autowired</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    BlogDAO blogDAO;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> List<span style="color:rgb(51, 153, 51);">&lt;</span>Blog<span style="color:rgb(51, 153, 51);">&gt;</span> searchBlogByKeyWord<span style="color:rgb(0, 153, 0);">(</span><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">String</span></a> keyword<span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 0, 0);font-weight:bold;">return</span> blogDAO.<span style="color:rgb(0, 102, 51);">searchByKeyword</span><span style="color:rgb(0, 153, 0);">(</span>keyword<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 102, 0);font-weight:bold;">void</span> setBlogDAO<span style="color:rgb(0, 153, 0);">(</span>BlogDAO blogDAO<span style="color:rgb(0, 153, 0);">)</span> <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 0, 0);font-weight:bold;">this</span>.<span style="color:rgb(0, 102, 51);">blogDAO</span> = blogDAO;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p></ol>
</div>
<p>Here is the test case for BlogSearchService,<br />In the test case, the ContextConfiguration helps in specifying the config file to load. In the @Before (setup method for the test case) I am creating the instance of BlogSearchServiceImpl (but instead you can autowire it). Then I am creating the mock object of blogDAO and setting it to the BlogSearchService.  In the actual test method, I expect that the searchBlogByKeyWord on the blogDAO and I am expecting it retuning no posts. You can do any asserts here depending on the actual business.
<p>  SpringJUnit4ClassRunner is a custom extension of <a href="http://junit.sourceforge.net/javadoc_40/org/junit/internal.runners.JUnit4ClassRunner.html?is-external=true" title="class or interface in org.junit"><code>JUnit4ClassRunner</code></a>  which provides functionality of the <em>Spring TestContext Framework</em>  to standard JUnit 4.4+ tests by means of the <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/test/context/TestContextManager.html" title="class in org.springframework.test.context"><code>TestContextManager</code></a> and  associated support classes and annotations.  </p>
<p>
<div class="java5 java5" style="border:1px solid rgb(208, 208, 208);font-family:monospace;color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">package</span> <span style="color:rgb(0, 102, 153);">com.teja.tests</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">java.util.Collections</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.junit.Before</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.junit.Test</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.junit.runner.RunWith</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.beans.factory.annotation.Autowired</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.test.context.ContextConfiguration</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">org.springframework.test.context.junit4.SpringJUnit4ClassRunner</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">import</span> <span style="color:rgb(0, 102, 153);">static</span> org.<span style="color:rgb(0, 102, 51);">easymock</span>.<span style="color:rgb(0, 102, 51);">EasyMock</span>.*;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;">/**</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> *</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> * @author Teja Kantamneni</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(102, 102, 102);font-style:italic;"> */</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">@RunWith<span style="color:rgb(0, 153, 0);">(</span>SpringJUnit4ClassRunner.<span style="color:rgb(0, 0, 0);font-weight:bold;">class</span><span style="color:rgb(0, 153, 0);">)</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">@ContextConfiguration<span style="color:rgb(0, 153, 0);">(</span>locations = <span style="color:rgb(0, 153, 0);">{</span><span style="color:rgb(0, 0, 255);">&#8220;classpath:beans.xml&#8221;</span><span style="color:rgb(0, 153, 0);">}</span><span style="color:rgb(0, 153, 0);">)</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">class</span> BlogSearchServiceTest <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    @Autowired</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    BlogSearchServiceImpl blogSearchService;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    BlogDAO blogDAO;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">            </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    @Before</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 102, 0);font-weight:bold;">void</span> setUp<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        blogSearchService = <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> BlogSearchServiceImpl<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        blogDAO = createMock<span style="color:rgb(0, 153, 0);">(</span>BlogDAO.<span style="color:rgb(0, 0, 0);font-weight:bold;">class</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        blogSearchService.<span style="color:rgb(0, 102, 51);">setBlogDAO</span><span style="color:rgb(0, 153, 0);">(</span>blogDAO<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    @Test</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 102, 0);font-weight:bold;">void</span> testSearchBlogByKeyword<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">String</span></a> keyword = <span style="color:rgb(0, 0, 255);">&#8220;spring&#8221;</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        expect<span style="color:rgb(0, 153, 0);">(</span>blogDAO.<span style="color:rgb(0, 102, 51);">searchByKeyword</span><span style="color:rgb(0, 153, 0);">(</span>keyword<span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span>.<span style="color:rgb(0, 102, 51);">andReturn</span><span style="color:rgb(0, 153, 0);">(</span><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html"><span style="color:rgb(0, 51, 153);font-weight:bold;">Collections</span></a>.<span style="color:rgb(0, 102, 51);">EMPTY_LIST</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        replay<span style="color:rgb(0, 153, 0);">(</span>blogDAO<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        blogSearchService.<span style="color:rgb(0, 102, 51);">searchBlogByKeyWord</span><span style="color:rgb(0, 153, 0);">(</span>keyword<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">        verify<span style="color:rgb(0, 153, 0);">(</span>blogDAO<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;">    <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-family:monospace;font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"> </div>
<p></li>
<p></ol>
</div>
<p>It&#8217;s so simple and sweet testing spring classes with jUnit and easymock. Isn&#8217;t it?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tejakantamneni.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tejakantamneni.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tejakantamneni.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tejakantamneni.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tejakantamneni.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tejakantamneni.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tejakantamneni.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tejakantamneni.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tejakantamneni.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tejakantamneni.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tejakantamneni.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tejakantamneni.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tejakantamneni.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tejakantamneni.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tejakantamneni.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tejakantamneni.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=4&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tejakantamneni.wordpress.com/2008/08/24/testing-spring-applications-with-junit-4-and-easy-mock/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d555c04f1b80fbe575c122979fd25e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tejakantamneni</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring Security &#8211; Using custom Authentication Processing Filter</title>
		<link>http://tejakantamneni.wordpress.com/2008/08/23/spring-security-using-custom-authentication-processing-filter/</link>
		<comments>http://tejakantamneni.wordpress.com/2008/08/23/spring-security-using-custom-authentication-processing-filter/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 23:15:00 +0000</pubDate>
		<dc:creator>tejakantamneni</dc:creator>
				<category><![CDATA[acegi]]></category>
		<category><![CDATA[spring security]]></category>
		<category><![CDATA[springframework]]></category>

		<guid isPermaLink="false">http://tejakantamneni.wordpress.com/2008/08/23/spring-security-using-custom-authentication-processing-filter/</guid>
		<description><![CDATA[Recently I got a chance working with Spring security, formerly known as Acegi Security for spring. While working with the framework, I heard comments from friends and colleagues saying that spring security lacks proper documentation. So thought of sharing a little knowledge. By the way, this is first ever blog posting and kindly excuse me [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=3&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I got a chance working with  Spring security, formerly known as Acegi Security for spring. While working with the framework, I heard comments from friends and colleagues saying that spring security lacks proper documentation. So thought of sharing a little knowledge. By the way, this is first ever blog posting and kindly excuse me and let me know any errors and improvements.</p>
<p>Spring security offers a simple configuration based security for your web applications helping you secure your web application with out littering your business logic with any security code. It provides securing URL&#8217;s based on the Role (Authorities), securing your business methods based on the ACL&#8217;s.</p>
<p>The first step in hooking up the spring security to your web application is by specifying the DelegatingFilterProxy in your web.xml.</p>
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;Spring security filter&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;filter<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;filter-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>springSecurityFilterChain<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/filter-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;filter-class<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>org.springframework.web.filter.DelegatingFilterProxy<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/filter-class<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/filter</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"> <span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;filter-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;filter-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>springSecurityFilterChain<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/filter-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>/*<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/url-pattern<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;dispatcher<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>REQUEST<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/dispatcher<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;dispatcher<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>INCLUDE<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/dispatcher<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;dispatcher<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>FORWARD<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/dispatcher<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/filter-mapping<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;End spring security filter&#8211;&gt;</span></div>
</li>
<p></ol>
</div>
<p>If you want to externalize all of your security related configuration into a separate file, you can do so and add that to your context location param.
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;context-param<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;param-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span>contextConfigLocation<span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/param-name<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">        <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;param-value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">                /WEB-INF/beans.xml , /WEB-INF/springSecurity.xml <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/param-value<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/context-param<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p></ol>
</div>
<p>Now comes the part of security configuration for your application, Adding the URL security patterns is pretty simple and straight forward. Add all the URL patterns which you want to secure and add the wild card pattern at the end. You need to have some default principal and role even for non logged in users as you need to give access to pages like log in, register and forgot password kind of functionality even to non logged in users.</p>
<p>I tried to add comments to pretty much every element which I am using here.<br />As an example I added just a wild card intercept url which make every page of my application secure. You need to exclude different urls based on the roles.</p>
<div class="xml xml" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(128, 128, 128);font-style:italic;"><!--enabling spring secuirty with custom authuntication--></span></div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:http</span> <span style="color:rgb(0, 0, 102);">entry-point-ref</span>=<span style="color:rgb(255, 0, 0);">&#8220;myAuthenticationEntryPoint&#8221;</span> <span style="color:rgb(0, 0, 102);">session-fixation-protection</span>=<span style="color:rgb(255, 0, 0);">&#8220;newSession&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;add any of your cusotom url patterns to protect&#8211;&gt;</span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:intercept-url</span> <span style="color:rgb(0, 0, 102);">pattern</span>=<span style="color:rgb(255, 0, 0);">&#8220;/login/**&#8221;</span> <span style="color:rgb(0, 0, 102);">access</span>=<span style="color:rgb(255, 0, 0);">&#8220;ROLE_ANONYMOUS&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:intercept-url</span> <span style="color:rgb(0, 0, 102);">pattern</span>=<span style="color:rgb(255, 0, 0);">&#8220;/register/**&#8221;</span> <span style="color:rgb(0, 0, 102);">access</span>=<span style="color:rgb(255, 0, 0);">&#8220;ROLE_ANONYMOUS&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:intercept-url</span> <span style="color:rgb(0, 0, 102);">pattern</span>=<span style="color:rgb(255, 0, 0);">&#8220;/**&#8221;</span> <span style="color:rgb(0, 0, 102);">access</span>=<span style="color:rgb(255, 0, 0);">&#8220;ROLE_USER&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:logout</span> <span style="color:rgb(0, 0, 102);">logout-success-url</span>=<span style="color:rgb(255, 0, 0);">&#8220;/home.htm&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:anonymous</span> <span style="color:rgb(0, 0, 102);">username</span>=<span style="color:rgb(255, 0, 0);">&#8220;guest&#8221;</span> <span style="color:rgb(0, 0, 102);">granted-authority</span>=<span style="color:rgb(255, 0, 0);">&#8220;ROLE_ANONYMOUS&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/security:http<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;name of my authenticationManager is authenticationManager&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:authentication-manager</span> <span style="color:rgb(0, 0, 102);">alias</span>=<span style="color:rgb(255, 0, 0);">&#8220;authenticationManager&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;Cutom login filter which replaces the default AUTHENTICATION_PROCESSING_FILTER &#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">id</span>=<span style="color:rgb(255, 0, 0);">&#8220;customizedFormLoginFilter&#8221;</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.security.ui.webapp.AuthenticationProcessingFilter&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;security:custom-filter</span> <span style="color:rgb(0, 0, 102);">position</span>=<span style="color:rgb(255, 0, 0);">&#8220;AUTHENTICATION_PROCESSING_FILTER&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span><span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;replace the default one&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;defaultTargetUrl&#8221;</span> <span style="color:rgb(0, 0, 102);">value</span>=<span style="color:rgb(255, 0, 0);">&#8220;/main.htm&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span><span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;After a successful login, the user will be taken to this page&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;authenticationFailureUrl&#8221;</span> <span style="color:rgb(0, 0, 102);">value</span>=<span style="color:rgb(255, 0, 0);">&#8220;/home.htm?error=true&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span><span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;Authentication failed? take him to error page&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;authenticationManager&#8221;</span> <span style="color:rgb(0, 0, 102);">ref</span>=<span style="color:rgb(255, 0, 0);">&#8220;myAuthenticationManager&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span> <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;Here it is the custom authenticationManager, login magic goes here &#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;allowSessionCreation&#8221;</span> <span style="color:rgb(0, 0, 102);">value</span>=<span style="color:rgb(255, 0, 0);">&#8220;true&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span> <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;Allow the application to create sessions&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;My custom auth manager&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">id</span>=<span style="color:rgb(255, 0, 0);">&#8220;myAuthenticationManager&#8221;</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;com.teja.security.CustomAuthunticationManager&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211; Automatically receives AuthenticationEvent messages &#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">id</span>=<span style="color:rgb(255, 0, 0);">&#8220;loggerListener&#8221;</span> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;org.springframework.security.event.authentication.LoggerListener&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(128, 128, 128);font-style:italic;">&lt;!&#8211;My authuntication entry point, can be replaced easily if we are doing custom commence of invalid auths.&#8211;&gt;</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;bean</span> <span style="color:rgb(0, 0, 102);">id</span>=<span style="color:rgb(255, 0, 0);">&#8220;myAuthenticationEntryPoint&#8221;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);"> <span style="color:rgb(0, 0, 102);">class</span>=<span style="color:rgb(255, 0, 0);">&#8220;com.teja.security.CustomAuthenticationEntryPoint&#8221;</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;">         <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;property</span> <span style="color:rgb(0, 0, 102);">name</span>=<span style="color:rgb(255, 0, 0);">&#8220;loginFormUrl&#8221;</span> <span style="color:rgb(0, 0, 102);">value</span>=<span style="color:rgb(255, 0, 0);">&#8220;/home.htm&#8221;</span><span style="color:rgb(0, 0, 0);font-weight:bold;">/&gt;</span></span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);"><span style="color:rgb(0, 0, 0);font-weight:bold;">&lt;/bean<span style="color:rgb(0, 0, 0);font-weight:bold;">&gt;</span></span></span></div>
</li>
<p></ol>
</div>
<p>Following is my custom implementation of AuthenticationEntryPoint, which currently is not doing any thing except leveraging the commence to its super class which is the spring implementation of  AuthenticationProcessingFilterEntryPoint. I hooked it to add any custom logic.</p>
<div class="java java" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">class</span> CustomAuthenticationEntryPoint <span style="color:rgb(0, 0, 0);font-weight:bold;">extends</span> AuthenticationProcessingFilterEntryPoint <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">private</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">static</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">final</span> Log logger <span style="color:rgb(51, 153, 51);">=</span> LogFactory.<span style="color:rgb(0, 102, 51);">getLog</span><span style="color:rgb(0, 153, 0);">(</span>CustomAuthenticationEntryPoint.<span style="color:rgb(0, 0, 0);font-weight:bold;">class</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> </div>
<p></li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> @Override</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 102);font-weight:bold;">void</span> commence<span style="color:rgb(0, 153, 0);">(</span>ServletRequest request, ServletResponse response, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aauthenticationexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">AuthenticationException</span></a> authException<span style="color:rgb(0, 153, 0);">)</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">IOException</span></a>, ServletException <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">super</span>.<span style="color:rgb(0, 102, 51);">commence</span><span style="color:rgb(0, 153, 0);">(</span>request, response, authException<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p></ol>
</div>
<p>This is my custom authentication manager which actually does the custom login of the user. It will throw an BadCredentialsException in case of invalid credentials or thorws a AuthenticationServiceException in case of a service error (Database error, SQL error or any other error).</p>
<div class="java java" style="border:1px solid rgb(208, 208, 208);color:rgb(0, 0, 102);background-color:rgb(240, 240, 240);font-family:monospace;">
<ol>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"><span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">class</span> CustomAuthunticationManager <span style="color:rgb(0, 0, 0);font-weight:bold;">implements</span> AuthenticationManager <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> @Autowired</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> UserManagerService userManagerService;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">public</span> Authentication authenticate<span style="color:rgb(0, 153, 0);">(</span>Authentication authentication<span style="color:rgb(0, 153, 0);">)</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aauthenticationexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">AuthenticationException</span></a> <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">if</span><span style="color:rgb(0, 153, 0);">(</span>StringUtils.<span style="color:rgb(0, 102, 51);">isBlank</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">String</span></a><span style="color:rgb(0, 153, 0);">)</span> authentication.<span style="color:rgb(0, 102, 51);">getPrincipal</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span> || StringUtils.<span style="color:rgb(0, 102, 51);">isBlank</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">String</span></a><span style="color:rgb(0, 153, 0);">)</span> authentication.<span style="color:rgb(0, 102, 51);">getCredentials</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">throw</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> BadCredentialsException<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 0, 255);">&#8220;Invalid username/password&#8221;</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> User user <span style="color:rgb(51, 153, 51);">=</span> <span style="color:rgb(0, 0, 102);font-weight:bold;">null</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> GrantedAuthority<span style="color:rgb(0, 153, 0);">[</span><span style="color:rgb(0, 153, 0);">]</span> grantedAuthorities <span style="color:rgb(51, 153, 51);">=</span> <span style="color:rgb(0, 0, 102);font-weight:bold;">null</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">try</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> user <span style="color:rgb(51, 153, 51);">=</span> userManagerService.<span style="color:rgb(0, 102, 51);">getUser</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">String</span></a><span style="color:rgb(0, 153, 0);">)</span> authentication.<span style="color:rgb(0, 102, 51);">getPrincipal</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>, <span style="color:rgb(0, 153, 0);">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">String</span></a><span style="color:rgb(0, 153, 0);">)</span> authentication.<span style="color:rgb(0, 102, 51);">getCredentials</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">catch</span><span style="color:rgb(0, 153, 0);">(</span>InvalidCredentialsException ex<span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">throw</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> BadCredentialsException<span style="color:rgb(0, 153, 0);">(</span>ex.<span style="color:rgb(0, 102, 51);">getMessage</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">catch</span><span style="color:rgb(0, 153, 0);">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color:rgb(0, 51, 153);">Exception</span></a> e<span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">throw</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> AuthenticationServiceException<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 0, 255);">&#8220;Currently we are unable to process your request. Kindly try again later.&#8221;</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">if</span> <span style="color:rgb(0, 153, 0);">(</span>user <span style="color:rgb(51, 153, 51);">!=</span> <span style="color:rgb(0, 0, 102);font-weight:bold;">null</span><span style="color:rgb(0, 153, 0);">)</span> <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> List<span style="color:rgb(51, 153, 51);">&lt;</span>Role<span style="color:rgb(51, 153, 51);">&gt;</span> roles <span style="color:rgb(51, 153, 51);">=</span> user.<span style="color:rgb(0, 102, 51);">getAssociatedRoles</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> grantedAuthorities <span style="color:rgb(51, 153, 51);">=</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> GrantedAuthority<span style="color:rgb(0, 153, 0);">[</span>roles.<span style="color:rgb(0, 102, 51);">size</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">]</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">for</span> <span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 0, 102);font-weight:bold;">int</span> i <span style="color:rgb(51, 153, 51);">=</span> 0; i <span style="color:rgb(51, 153, 51);">&amp;</span>lt; roles.<span style="color:rgb(0, 102, 51);">size</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>; i<span style="color:rgb(51, 153, 51);">++</span><span style="color:rgb(0, 153, 0);">)</span> <span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> Role role <span style="color:rgb(51, 153, 51);">=</span> roles.<span style="color:rgb(0, 102, 51);">get</span><span style="color:rgb(0, 153, 0);">(</span>i<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> GrantedAuthority authority <span style="color:rgb(51, 153, 51);">=</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> GrantedAuthorityImpl<span style="color:rgb(0, 153, 0);">(</span>role.<span style="color:rgb(0, 102, 51);">getRoleCode</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> grantedAuthorities<span style="color:rgb(0, 153, 0);">[</span>i<span style="color:rgb(0, 153, 0);">]</span> <span style="color:rgb(51, 153, 51);">=</span> authority;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);font-family:monospace;margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">else</span><span style="color:rgb(0, 153, 0);">{</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">throw</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> BadCredentialsException<span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 0, 255);">&#8220;Invalid username/password&#8221;</span><span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"> <span style="color:rgb(0, 0, 0);font-weight:bold;">return</span> <span style="color:rgb(0, 0, 0);font-weight:bold;">new</span> UsernamePasswordAuthenticationToken<span style="color:rgb(0, 153, 0);">(</span>user, authentication.<span style="color:rgb(0, 102, 51);">getCredentials</span><span style="color:rgb(0, 153, 0);">(</span><span style="color:rgb(0, 153, 0);">)</span>, grantedAuthorities<span style="color:rgb(0, 153, 0);">)</span>;</div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"> <span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p>
<li>
<div style="font-weight:normal;font-style:normal;color:rgb(0, 0, 32);margin:0;padding:0;"><span style="color:rgb(0, 153, 0);">}</span></div>
</li>
<p></ol>
</div>
<p>At the client side (jsp), the simple configuration you need to do is post the request to&#8221;/j_spring_security_check&#8221; with parameters &#8220;j_username&#8221; and &#8220;j_password&#8221;.</p>
<p>That&#8217;s pretty much all you need to do for enabling spring security to your existing web application. I will try to explain about doing the method security using ACL&#8217;s and configuring the view using spring security tags in another post.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tejakantamneni.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tejakantamneni.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tejakantamneni.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tejakantamneni.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tejakantamneni.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tejakantamneni.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tejakantamneni.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tejakantamneni.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tejakantamneni.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tejakantamneni.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tejakantamneni.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tejakantamneni.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tejakantamneni.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tejakantamneni.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tejakantamneni.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tejakantamneni.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tejakantamneni.wordpress.com&amp;blog=4605571&amp;post=3&amp;subd=tejakantamneni&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tejakantamneni.wordpress.com/2008/08/23/spring-security-using-custom-authentication-processing-filter/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d555c04f1b80fbe575c122979fd25e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tejakantamneni</media:title>
		</media:content>
	</item>
	</channel>
</rss>
