<?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/"
	>

<channel>
	<title>walgemoed.org</title>
	<atom:link href="http://www.walgemoed.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.walgemoed.org</link>
	<description>Jarno Walgemoed&#039;s blog</description>
	<lastBuildDate>Mon, 23 May 2011 21:53:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>&#8216;Studio&#8217; Redesign</title>
		<link>http://www.walgemoed.org/2011/05/studio-redesign/</link>
		<comments>http://www.walgemoed.org/2011/05/studio-redesign/#comments</comments>
		<pubDate>Mon, 23 May 2011 21:53:44 +0000</pubDate>
		<dc:creator>jwalgemoed</dc:creator>
				<category><![CDATA[Home Studio]]></category>

		<guid isPermaLink="false">http://www.walgemoed.org/?p=128</guid>
		<description><![CDATA[One of my biggest passions is music, and in my spare time I take amateuristic stabs at creating tunes (mainly for my own listening pleasure). I&#8217;ve been working on setting up a new &#8216;home studio&#8217;, to facilitate my hobby needs &#8230;<p class="read-more"><a href="http://www.walgemoed.org/2011/05/studio-redesign/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>One of my biggest passions is music, and in my spare time I take amateuristic stabs at creating tunes (mainly for my own listening pleasure). I&#8217;ve been working on setting up a new &#8216;home studio&#8217;, to facilitate my hobby needs and thought I might share how far I&#8217;d come here. The basic elements are (in no particular order):</p>
<ul>
<li>Audio Interface (required to get sound in and out of the computer &#8211; preferably a bit better in quality than a soundblaster)</li>
<li>Reference monitors &#8211; Nearfield (Reference monitors to mix on, that work better than your typical logitech speaker sets)</li>
<li>Midi input devices (Ranging from keyboards, to padkontrollers to synths to fullblown drum kits)</li>
<li>Midi Controllers (Devices to use when mixing, controlling parameters on software synths)</li>
<li>Digital Audio Workstation software (DAW) &#8211; (Ableton Live, Reason)</li>
<li>DJ Software (Traktor Pro)</li>
</ul>
<p>I&#8217;ve spent a reasonable chunk of time setting all this up last weekend. Continue onwards for the progress report.<span id="more-128"></span></p>
<p>As my main sequencing is done in a free version of Ableton live (which came with some hardware), which I augmented with a library of free VST instuments I need a proper audio interface with low-latency drivers to work with. Until now, I used an old X-Fi soundblaster, but that just doesn&#8217;t cut it anymore. Also, me using low-class Logitech speakers to mix on wasn&#8217;t really helping much. Although I didn&#8217;t own a lot of hardware, I managed to compile quite an extensive library of samples (from records I own, and loads and loads of free samples from the net) so I have enough stuff to work with.</p>
<p>I reserved a vacant room in my home for this, and decided to move a pc from the office to the aforementioned room. I then started setting up the main parts of my previous setup, the <a href="http://www.korg.com/product.aspx?pd=252">Korg K25</a>, the <a href="http://www.korg.com/product.aspx?pd=414">Korg PadKontrol</a>, the <a href="http://www.m-audio.com/products/en_us/Axiom49.html">M-Audio Axiom 49</a>, and finally my <a href="http://frontierdesign.com/Products/AlphaTrack">Frontier Design AlphaTrack</a>. This pretty much ate up all my available USB ports. Also the PSU wasn&#8217;t strong enough to power all this hardware using USB so a few universal power supplies happily came to the rescue.</p>
<p>So, next up was extending this already quite luxurious setup to create the studio I always wanted (but on a budget ofcourse <img src='http://www.walgemoed.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  &#8211; tight budget even). Â What I decided I would &#8216;need&#8217; (want) was a reasonably priced audio interface with balanced outputs, USB connectivity (as I would be using a pc that didn&#8217;t have firewire) and a decent set of inputs. I guessed I would need two at most so when I came across the <a href="http://www.focusrite.com/products/saffire/saffire_6_usb">Focusrite Sapphire 6 USB audio interface</a>, I figured it would fit the bill. Reviews of this device are all pretty positive, so I can hardly go wrong with this one, can I? I&#8217;ll have to wait for it to arrive before I can give any proper feedback on its performance, but I&#8217;m pretty sure that it will outperform my Soundblaster X-Fi with ease. A good sounding audio interface needs decent quality studio monitors to reach I potential, I figure. That&#8217;s why I went to the nearest <a href="http://www.feedback.nl">Feedback</a> store to listen to some of the available monitors. At first I read some reviews on the <a href="http://www.krksys.com/product_rokit.php">KRK Rokit 6/8</a> monitors that were supposed to be pretty decent, but after listening to them in the store I felt they lacked mid-range. The guy assisting me in the store advised me to listen to <a href="http://www.adam-audio.com/en/pro-audio/products/a5x/description">Adam a5x</a> monitors, and they sounded really good. Really solid rounded sound with plenty of low and mid and not to much high. Apparently I&#8217;m not the only one hearing the quality in these monitors, as they are pretty hard to come by. I contacted the guys at Feedback if the slightly bigger model would be available, the <a href="http://www.adam-audio.com/en/pro-audio/products/a7x/description">Adam a7x</a>. I might just decide to go with that set. They look better than Rokit&#8217;s as well, nice added bonus.</p>
<p>I&#8217;ve had an old microphone for ages, which I used to sample household items and appliances with. It was rubbish and the sound quality was pretty awful. As I do not require a high-end microphone for recording vocals, I decided to go with a budget version. The <a href="http://www.mxlmics.com/products/Kits/DRK/DRK.html">MXL DRK Desktop Recording Kit</a> comes with a decent little stand, can operate on phantom power delivered by the Focusrite audio interface, isn&#8217;t too expensive and gets reasonable reviews. I might have to add a pop-filter to the set, but I&#8217;m guessing this will do nicely for my intended purposes. In the reviews I&#8217;ve found covering this mic I noticed that recording instruments and vocals also yield decent results, so who knows I might be doing something with that as well.</p>
<p>Recently I finally got to purchase something I&#8217;ve wanted to own ever since I was a kid, which is a proper drum kit. As I don&#8217;t have the money to live in a villa where no-one can hear me make noise, I had to go with an electric one. The <a href="http://www.roland.com/products/en/TD-9K/">Roland TD-9K</a> felt like a good-featured kit to me, so I bought it. I haven&#8217;t regretted the purchase for one second. I previously played my drumtracks on my PadKontrol, but I since then moved to the midi-out capabilities of the Roland kit. A lot of fun to play. The PadKontrol is now mainly used for audio triggering.</p>
<p>The stuff I jotted down here pretty much makes up a decent home studio on-a-budget, I guess. The one last thing I had on my list was that I still wanted to learn how to DJ. I didn&#8217;t want to invest in decks and mixers and such, and decided to go with software DJ-ing. <a href="http://www.native-instruments.com/#/en/products/dj/traktor-pro-2/">Native Instruments Traktor</a> is a good offering in that respect, and when I was looking into that I noticed a pretty cool new hardware controller by Native Instruments. The <a href="http://www.native-instruments.com/#/en/products/dj/traktor-kontrol-s4/?src=navi">Traktor Kontrol S4</a> not only looks the part, but also boasts a pretty decent set of features. Techzine <a href="http://www.engadget.com">Engadget</a> posted an interesting <a href="http://www.engadget.com/2010/11/09/native-instruments-traktor-kontrol-s4-review/">review</a> of the device, and after looking at some video&#8217;s of this puppy in action I decided I should add this to my gearlist as well.</p>
<p>After writing this bit of proze, I went ahead and purchased it all. All is ready to get to work, now all that&#8217;s needed is some inspiration and free time. Both are pretty sparse at the moment. Best get started on the plugin installs&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.walgemoed.org/2011/05/studio-redesign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Honeycomb SDK preview out</title>
		<link>http://www.walgemoed.org/2011/01/android-honeycomb-sdk-preview-out/</link>
		<comments>http://www.walgemoed.org/2011/01/android-honeycomb-sdk-preview-out/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 09:51:38 +0000</pubDate>
		<dc:creator>jwalgemoed</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Honeycomb]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.walgemoed.org/?p=119</guid>
		<description><![CDATA[The competition on the market for tablets is finally intensifying. Soon the Motorola Xoom and Toshiba tablet will be released to the general public and everyone will finally be able to choose a serious tablet that&#8217;s not an iPad. These &#8230;<p class="read-more"><a href="http://www.walgemoed.org/2011/01/android-honeycomb-sdk-preview-out/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>The competition on the market for tablets is finally intensifying. Soon the <a href="http://www.motorola.com/Consumers/US-EN/Consumer-Product-and-Services/Tablets/ci.MOTOROLA-XOOM-US-EN.overview">Motorola Xoom</a> and <a href="http://thetoshibatablet.com/">Toshiba tablet</a> will be released to the general public and everyone will finally be able to choose a serious tablet that&#8217;s not an iPad. These new tablets will feature Google&#8217;s tablet optimized version of Android, 3.0 &#8211; Honeycomb. Many are slated to follow containing the same OS.</p>
<p>Quite a few sources on the net have already posted their comments on this new Android release, ranging from potential iPad killer to absolute rubbish. I&#8217;ve been taken with Android since it was released so I can&#8217;t claim to be unpartial but I&#8217;m definately impressed by the way it looks. Screenshots are <a href="http://www.oudmaijer.com/2011/01/27/android-3-0-sdk-preview/">everywhere</a> on the net, have a look and judge for yourself.</p>
<p>Also,Â <a href="http://www.youtube.com/watch?v=M-80QD5Zjyc">Google released a Honeycomb Preview Video</a> that quite clearly shows the immense progress they&#8217;ve made with the Android platform. It&#8217;s really starting to look like a proper tablet OS.<span id="more-119"></span></p>
<h3>SDK</h3>
<p>As a Java developer that&#8217;s interested in development for mobile platforms, I can&#8217;t wait to get started with this. Luckily the Honeycomb preview SDK has been released so I had the opportunity to play around a bit. Although the emulator is quite tardy the overall experience is pretty impressive. Android looks very good and is optimized for tablet usage. Let&#8217;s hope Motorola and Toshiba get their devices on the market soon so I can start coding my first prototype tablet apps. It&#8217;s still early days for the emulator but I&#8217;m guessing the final version is just around the corner.</p>
<p>The SDK is available from the <a href="http://developer.android.com/sdk/index.html">Google Android developer site</a>.</p>
<h3>Reviews</h3>
<p>A good article about the new SDK can be found <a href="http://leihwelt.wordpress.com/2011/01/27/android-3-0-the-wait-is-over/">here</a>. The article also describes the developer point of view and is quite thorough. Nice read.</p>
<p>If you are new to tablets and are still thinking about buying an iPad &#8211; hold off for a while. Wait for the new Android tablets to drop. You may change your mind about Apple&#8217;s baby after all&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.walgemoed.org/2011/01/android-honeycomb-sdk-preview-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GZip RestTemplate</title>
		<link>http://www.walgemoed.org/2011/01/gzip-resttemplate/</link>
		<comments>http://www.walgemoed.org/2011/01/gzip-resttemplate/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 15:06:55 +0000</pubDate>
		<dc:creator>jwalgemoed</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[GZIP]]></category>
		<category><![CDATA[JAXB2]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.walgemoed.org/?p=96</guid>
		<description><![CDATA[This weekend I created a small application that could gather information from the DISCOGS website using a RESTFul webservice they so very kindly provided. While I already had some previous experience using the RestTemplate provided by Spring I figured it &#8230;<p class="read-more"><a href="http://www.walgemoed.org/2011/01/gzip-resttemplate/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>This weekend I created a small application that could gather information from the DISCOGS website using a RESTFul webservice they so very kindly provided. While I already had some previous experience using the RestTemplate provided by Spring I figured it would be a good idea to start there.</p>
<p>As with most of things IT related it didn&#8217;t all go according to plan. The RestTemplate I used didn&#8217;t support the gzip stream that was returned by the REST service published by Discogs. So how to fix this? There are two ways.<span id="more-96"></span></p>
<p>Firstly, you can use the exchange method included in the RestTemplate. I personally find this approach a bit verbose. Here it is:</p>
<pre class="brush: java; title: ;">
HttpHeaders headers = new HttpHeaders();
headers.set(&quot;Accept-Encoding&quot;, &quot;gzip,deflate&quot;);

T response = getRestTemplate().exchange(url,
					HttpMethod.POST,
					new HttpEntity&lt;String&gt;(headers),
					responseType).getBody();
</pre>
<p>A nicer solution (as far as I am concerned) is extending the RestTemplate to create a GZip enabled template. Stephan Oudmaijer provided me with this code which I found pretty useful. In the code it&#8217;s more obvious you are using the resttemplate with gzip support, and you don&#8217;t have to change any code if you need the standard RestTemplate. It is somewhat less verbose than using the exchange method.</p>
<pre class="brush: java; highlight: [29,30]; title: ;">
package org.walgemoed.util;

import java.io.IOException;
import java.net.URI;

import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.Assert;
import org.springframework.web.client.RequestCallback;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.ResponseExtractor;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

/**
 * Fix for missing gzip support in Spring RestTemplate
 */
public class GZipRestTemplate extends RestTemplate {

	@Override
	protected &lt;T&gt; T doExecute(URI url, HttpMethod method,
			RequestCallback requestCallback,
			ResponseExtractor&lt;T&gt; responseExtractor) throws RestClientException {
		Assert.notNull(url, &quot;'url' must not be null&quot;);
		Assert.notNull(method, &quot;'method' must not be null&quot;);
		ClientHttpResponse response = null;
		try {
			ClientHttpRequest request = createRequest(url, method);
			request.getHeaders().add(&quot;Accept-Encoding&quot;, &quot;gzip,deflate&quot;);

			if (requestCallback != null) {
				requestCallback.doWithRequest(request);
			}
			response = request.execute();

			if (!getErrorHandler().hasError(response)) {
				logResponseStatus(method, url, response);
			} else {
				handleResponseError(method, url, response);
			}
			if (responseExtractor != null) {
				return responseExtractor.extractData(response);
			} else {
				return null;
			}
		} catch (IOException ex) {
			throw new ResourceAccessException(&quot;I/O error: &quot; + ex.getMessage(),
					ex);
		} finally {
			if (response != null) {
				response.close();
			}
		}
	}

	private void handleResponseError(HttpMethod method, URI url,
			ClientHttpResponse response) throws IOException {
		if (logger.isWarnEnabled()) {
			try {
				logger.warn(method.name() + &quot; request for \&quot;&quot; + url
						+ &quot;\&quot; resulted in &quot; + response.getStatusCode() + &quot; (&quot;
						+ response.getStatusText()
						+ &quot;); invoking error handler&quot;);
			} catch (IOException e) {
				// ignore
			}
		}
	}

	private void logResponseStatus(HttpMethod method, URI url,
			ClientHttpResponse response) {
		if (logger.isDebugEnabled()) {
			try {
				logger.debug(method.name() + &quot; request for \&quot;&quot; + url
						+ &quot;\&quot; resulted in &quot; + response.getStatusCode() + &quot; (&quot;
						+ response.getStatusText() + &quot;)&quot;);
			} catch (IOException e) {
				// ignore
			}
		}
	}
}
</pre>
<p>Some handling is still required, as you can see Exceptions are ignored in this snippet. The highlighted lines show where the gzip accept header is added to the mix in the template. After setting this header the resulting stream will be handled correctly. After using this template I was able to consume the REST services from Discogs.</p>
<p>Would still be nice to see easy gzip support in the RestTemplate by default though. Maybe in the future? For now this will do. For any of you interested in the code to execute searches on Discogs, let me know. I may be tempted to clean up the code and provide a generic API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.walgemoed.org/2011/01/gzip-resttemplate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Noisia &#8211; Split the Atom</title>
		<link>http://www.walgemoed.org/2010/12/nosia-split-the-atom/</link>
		<comments>http://www.walgemoed.org/2010/12/nosia-split-the-atom/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 11:37:26 +0000</pubDate>
		<dc:creator>jwalgemoed</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Noisia]]></category>
		<category><![CDATA[Split The Atom]]></category>

		<guid isPermaLink="false">http://www.walgemoed.org/?p=79</guid>
		<description><![CDATA[As far as I&#8217;m concerned, I thought it was about time that the Groningen based Drum&#38;Bass producer trio known by the name Noisia released a full-length album on CD. I am aware that in the confines of the Drum&#38;Bass scene, &#8230;<p class="read-more"><a href="http://www.walgemoed.org/2010/12/nosia-split-the-atom/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.walgemoed.org/wp-content/uploads/2010/12/splittheatom.jpg"><img class="alignright size-full wp-image-80" title="splittheatom" src="http://www.walgemoed.org/wp-content/uploads/2010/12/splittheatom.jpg" alt="" width="225" height="225" /></a> As far as I&#8217;m concerned, I thought it was about time that the Groningen based Drum&amp;Bass producer trio known by the name Noisia released a full-length album on CD. I am aware that in the confines of the Drum&amp;Bass scene, the tiny shiny discs are frowned upon somewhat. Only 12&#8243; vinyl has any street-cred, so I can understand why it took all this time for them to compile a proper CD album.</p>
<p>I&#8217;m glad they finally did though. This album simply is one of the best dance albums I have encountered in quite some time. There is quite a unique diversity in tracks, so it&#8217;s not just a compilation of drum&amp;bass tracks. The collaboration with foreign beggars results in familiar sounding tracks, but Giovanca&#8217;s appearance on &#8216;this world&#8217; adds a bit of spice to the mix. Title track &#8216;Split the Atom&#8217; is my favourite track though, it&#8217;s solid buildup and earth-shaking basslines are yet unmatched by any track I&#8217;ve heard before. Other favourites include the drum&amp;bass stomper call &#8216;Stigma&#8217;, the whacky track &#8216;Diplodocus&#8217; and &#8216;Red Heat&#8217;. &#8216;Alpha Centauri&#8217; is also an excellent listen!</p>
<p>Does this mean the rest of the tracks are just filler? Well, no. There are a few less sparkly gems on the disc, but they are gems nonetheless. Highly recommended!</p>
<p></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.walgemoed.org/2010/12/nosia-split-the-atom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic JAXB2 &amp; Spring-WS</title>
		<link>http://www.walgemoed.org/2010/12/jaxb2-spring-ws/</link>
		<comments>http://www.walgemoed.org/2010/12/jaxb2-spring-ws/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 12:00:00 +0000</pubDate>
		<dc:creator>jwalgemoed</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[JAXB2]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring-WS]]></category>

		<guid isPermaLink="false">http://www.walgemoed.org/?p=20</guid>
		<description><![CDATA[While working on a project recently I was faced with the task to define a couple of webservices. As my application is completely based on Spring, the logical choice (in my book) would be using Spring-WS. After some deliberation I &#8230;<p class="read-more"><a href="http://www.walgemoed.org/2010/12/jaxb2-spring-ws/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>While working on a project recently I was faced with the task to define a couple of webservices. As my application is completely based on Spring, the logical choice (in my book) would be using Spring-WS. After some deliberation I decided to go with classic Soap based webservices, as the application that would be calling my services did not support REST. Also, Axis 1 was already in place, so integration with that framework was considered important.</p>
<p>I did however want the solution to be as hassle-free as possible. Even though it&#8217;s contract first, I didn&#8217;t want to spend a lot of time messing about with XSD&#8217;s and WSDL and decided toÂ try and generate both of these artifacts based on my Java code.Â As JAXB2 supportsÂ annotation basedÂ definition of the resulting XML structure IÂ decided to use that framework to fulfil my marshalling needs. Spring-WS integration with JAXB2 is pretty decent, so why not?<span id="more-20"></span></p>
<h2>Maven2</h2>
<p>I&#8217;m using maven to manage my dependencies, nothing special there. Additionally, I&#8217;m going to be looking to Maven to supply me with a mechanism for generating the XSD and packaging it within the application. First, I&#8217;ll start by adding the dependencies.</p>
<pre class="brush: xml; title: ;">
&lt;dependency&gt;
	&lt;groupId&gt;org.springframework.ws&lt;/groupId&gt;
	&lt;artifactId&gt;spring-ws-core&lt;/artifactId&gt;
	&lt;version&gt;1.5.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;org.springframework.ws&lt;/groupId&gt;
	&lt;artifactId&gt;spring-xml&lt;/artifactId&gt;
	&lt;version&gt;1.5.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;org.springframework.ws&lt;/groupId&gt;
	&lt;artifactId&gt;spring-oxm&lt;/artifactId&gt;
	&lt;version&gt;1.5.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;org.springframework.ws&lt;/groupId&gt;
	&lt;artifactId&gt;spring-oxm-tiger&lt;/artifactId&gt;
	&lt;version&gt;1.5.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;org.springframework.ws&lt;/groupId&gt;
	&lt;artifactId&gt;spring-ws-core-tiger&lt;/artifactId&gt;
	&lt;version&gt;1.5.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;org.springframework.ws&lt;/groupId&gt;
	&lt;artifactId&gt;spring-ws-support&lt;/artifactId&gt;
	&lt;version&gt;1.5.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;sun-jaxb&lt;/groupId&gt;
	&lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
	&lt;version&gt;2.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;sun-jaxb&lt;/groupId&gt;
	&lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
	&lt;version&gt;2.2&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>In this snippet I will assume for brevity that all required Spring 3 libraries have already been added. Drop me a line if you want to know the contents of the complete pom.</p>
<h2>Servlet configuration</h2>
<p>As Spring-WS works using a servlet to handle requests, the first thing I&#8217;ll have to do is set up this servlet. I&#8217;m going to handle requests using the /services/ mapping.</p>
<pre class="brush: xml; title: ;">
&lt;servlet&gt;
  &lt;servlet-name&gt;services&lt;/servlet-name&gt;
  &lt;servlet-class&gt;
	org.springframework.ws.transport.http.MessageDispatcherServlet&lt;/servlet-class&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;transformWsdlLocations&lt;/param-name&gt;
    &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;services&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/services/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</pre>
<p>This should allow Spring-WS to handly my requests. Interesting bit of configuration is the usage of the contextConfigLocation parameter. The value is omitted to allow the default contextLoaderListener to pick up the configuration and wire everything together. So, after handling this, next up is the Spring configuration.</p>
<h2>Spring configuration</h2>
<p>This is where it gets a little tricky. Well, actually it&#8217;s not that bad.</p>
<pre class="brush: xml; title: ;">
&lt;bean class=&quot;org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping&quot; /&gt;

&lt;bean id=&quot;marshaller&quot;
	class=&quot;org.walgemoed.util.ClasspathScanningJAXB2Marshaller&quot;&gt;
	&lt;property name=&quot;schema&quot; value=&quot;classpath:my-service.xsd&quot; /&gt;
	&lt;property name=&quot;basePackage&quot; value=&quot;org.walgemoed&quot; /&gt;
&lt;/bean&gt;

&lt;bean
	class=&quot;org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter&quot;&gt;
	&lt;property name=&quot;marshaller&quot; ref=&quot;marshaller&quot; /&gt;
	&lt;property name=&quot;unmarshaller&quot; ref=&quot;marshaller&quot; /&gt;
&lt;/bean&gt;

&lt;bean id=&quot;supportcms&quot;
	class=&quot;org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition&quot;&gt;
	&lt;property name=&quot;builder&quot;&gt;
		&lt;bean
			class=&quot;org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder&quot;&gt;
			&lt;property name=&quot;schema&quot; value=&quot;classpath:my-service.xsd&quot; /&gt;
			&lt;property name=&quot;portTypeName&quot; value=&quot;my-service&quot; /&gt;
			&lt;property name=&quot;locationUri&quot; value=&quot;/services/&quot; /&gt;
		&lt;/bean&gt;
	&lt;/property&gt;
&lt;/bean&gt;
</pre>
<p>Four pieces of configuration are required to publish my services. The first bean I&#8217;m setting up is the PayloadRootAnnotationMethodEndpointMapping component. This Spring component will register any classes that are annotated with @Endpoint, and pick up any methods annotated with @PayloadRoot. These methods will define the actual services I am offering. I can still define services without this bean, but that&#8217;d mean I have to specify this endpoint manually in my Spring configuration. I&#8217;m lazy by nature, so annotating the class should be sufficient as far as I am concerned.</p>
<p>Next up is the marshaller. I&#8217;m configuring a custom ClasspathScanningJAXB2Marshaller, which I built myself. It uses the Spring classpath scanning mechanism to look for annotated JAXB2 beans. They then are added to a list of classes that are XML roots. Why use classpath scanning? The default implementation supplied by Spring requires you to manually specify any class that you want to be able to marshal. Again, I hate having to annotate the class AND register it in my configuration so I&#8217;m just going to automatically discover and register them.</p>
<pre class="brush: java; title: ;">
/**
 * JAXBMarshaller extension that uses Spring API to autodetect and autowire
 * JAXB2 XML root elements. Saves the hassle of having to add them to the Spring
 * configuration manually.
 *
 * Error messages returned by Spring-WS aren't too clear, so welcome addition.
 *
 * @author Jarno
 *
 */
public class ClasspathScanningJAXB2Marshaller extends Jaxb2Marshaller {

	private String basePackage;

	private Logger logger = Logger
			.getLogger(ClasspathScanningJAXB2Marshaller.class);

	/**
	 * Constructor. Applies Spring specific API in order to get the RootNode
	 * annotated classes for JAXB serialization.
	 */
	@PostConstruct
	public void init() {
		logger.info(&quot;--- Attempting to scan classpath for JAXB2 annotated elements ---&quot;);
		this.setClassesToBeBound(getXMLRootClasses());
		logger.info(&quot;--- Scan complete ---&quot;);
	}

	/**
	 * Uses Spring classpath scanning implementation to scan for annotated
	 * classes. Classes that have the specific JAXB annotation for rootnodes
	 * will be added to the Class [].
	 *
	 * @return Class array of classes that are annotated as rootnodes
	 */
	public final Class&lt;?&gt;[] getXMLRootClasses() {
		ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
				false);

		scanner.addIncludeFilter(new AnnotationTypeFilter(XmlRootElement.class));

		try {
			Set&lt;BeanDefinition&gt; components = scanner
					.findCandidateComponents(basePackage);
			Class&lt;?&gt;[] result = new Class[components.size()];
			int i = 0;
			for (BeanDefinition bd : components) {
				result[i] = this.getClass().getClassLoader().loadClass(bd.getBeanClassName());
				logger.info(&quot;Found class &quot; + bd.getBeanClassName());
				i++;
			}
			return result;
		}
		// Not gonna happen, we are scanning - not guessing
		catch (ClassNotFoundException cnfe) {
			return new Class&lt;?&gt;[0];
		}
	}

	public void setBasePackage(String basePackage) {
		this.basePackage = basePackage;
	}
}
</pre>
<p>I just extended the class and am using lifecycle callbacks to find out when Spring has completed initialisation. I also added a basePackage property, which defines the base package to start scanning in. As you can see in the Spring configuration, I supplied it with a value. The package org.walgemoed will be scanned for JAXB2 elements that are annotated as XmlRootNodes.</p>
<p>The third bit of configuration is the Spring genericMarshallingEndpointAdapter. This little beast will wire itself using my newly created marshaller and automatically try to marshal and unmarshal any XML I throw at it. As I have done my very best to auto-register the XmlRootNodes, I think this will work out quite nicely. I&#8217;m also adding the XSD to the configuration. I&#8217;m not using that now, but you can use the validating property on the bean configuration to have Spring validate the XML against the XSD. This is pretty neat as it will generate specific messages on why your XML isn&#8217;t correctly formed.</p>
<p>The final bit of configuration will allow me to automatically generate a WSDL for my services. I&#8217;m all for that, as I don&#8217;t want to do that manually. There are a couple of settings that are important. First of all, a Soap1.1DefinitionBuilder is used. This will generate a Soap1.1 specific WSDL. This will meet my needs, but if you are looking for Soap 1.2 this is also supported. Not gonna spell it out for ya though <img src='http://www.walgemoed.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . The definition generator takes a few property settings, schema, portTypeName and locationURI. The schema defines the contract for the service, so I&#8217;m going to go ahead and add the exact same schema as I did for my marshaller. They should match, right? The locationURI specifies where the service will be deployed. As I&#8217;ve configured my servlet to be listening for requests on /services/ I&#8217;m using that setting here. Finally, I&#8217;m going to specify the name for my services by specifying the portType.</p>
<p>After doing this, and after finishing my configuration the WSDL should be accessible via: http://&lt;server&gt;:&lt;port&gt;/&lt;context-root/services/my-service.wsdl</p>
<h2>XSD generation</h2>
<p>I still can&#8217;t deploy my app though, as I don&#8217;t have the XML structure yet. I don&#8217;t want that job to be a manual activity, as I don&#8217;t want to re-generate my XSD every time the signature of my XML changes. At least, not during development. Good thing I&#8217;m using JAXB2, as there is a plugin that will automatically generate the XSD for me, based on the JAXB2 annotations on my classes! I&#8217;ve added the plugin to my application and configured it to execute this generation every time I build my project.</p>
<pre class="brush: xml; title: ;">
&lt;!-- Plugin mojo that can be used to generate XSD files before deployment. --&gt;
&lt;plugin&gt;
	&lt;groupId&gt;com.sun.tools.jxc.maven2&lt;/groupId&gt;
	&lt;artifactId&gt;maven-jaxb-schemagen-plugin&lt;/artifactId&gt;
	&lt;version&gt;1.2&lt;/version&gt;
	&lt;executions&gt;
		&lt;execution&gt;
			&lt;phase&gt;generate-resources&lt;/phase&gt;
			&lt;goals&gt;
				&lt;goal&gt;generate&lt;/goal&gt;
			&lt;/goals&gt;
		&lt;/execution&gt;
	&lt;/executions&gt;
	&lt;configuration&gt;
		&lt;destdir&gt;${project.build.directory}/schemas&lt;/destdir&gt;
		&lt;srcdir&gt;${project.build.sourceDirectory}/org/walgemoed/&lt;/srcdir&gt;
		&lt;verbose&gt;true&lt;/verbose&gt;
	&lt;/configuration&gt;
&lt;/plugin&gt;
</pre>
<p>This will generate a schema file in the target/schemas folder for my maven2 project. All I need to do now is include it in my application. I used to antrun plugin for maven to do this, but there are many other ways. As you can see, I&#8217;m also changing the name. There is another way to do this as well, but hey, this works for me.</p>
<pre class="brush: xml; title: ;">
&lt;plugin&gt;
	&lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
	&lt;executions&gt;
		&lt;execution&gt;
			&lt;phase&gt;compile&lt;/phase&gt;
			&lt;goals&gt;
				&lt;goal&gt;run&lt;/goal&gt;
			&lt;/goals&gt;
			&lt;configuration&gt;
				&lt;tasks&gt;
					&lt;copy file=&quot;${project.build.directory}/org/walgemoed/schema1.xsd&quot;
						tofile=&quot;${project.build.outputDirectory}/my-service.xsd&quot; /&gt;
				&lt;/tasks&gt;
			&lt;/configuration&gt;
		&lt;/execution&gt;
	&lt;/executions&gt;
&lt;/plugin&gt;
</pre>
<h2>Done!</h2>
<p>Well, almost. Configuration is done, yes. I&#8217;ve set up XSD generation, rigged automatic marshalling with JAXB2, added scanning for root elements, set up the servlet AND pimped my build process. What could possibly be left?</p>
<h2>Defining a service: EchoService</h2>
<p>Right, I didn&#8217;t build a service yet. Usually a service consists of a request and an response. I like this approach so I&#8217;m going to be using ServiceRequest and ServiceResponse classes for my service. The request will contain a parameter called echo, and the response is going to echo that same parameter three times. This is a very useful service indeed.</p>
<p>Here&#8217;s the request:</p>
<pre class="brush: java; title: ;">
@XmlRootElement(namespace = NameSpaceConstant.namespace)
@XmlType(namespace = NameSpaceConstant.namespace)
public class EchoRequest {

	private String echo;

	@XmlElement(namespace = NameSpaceConstant.namespace, required = true)
	public String getEcho() {
		return echo;
	}

	public void setEcho(String echo) {
		this.echo = echo;
	}
}
</pre>
<p>And here&#8217;s the response:</p>
<pre class="brush: java; title: ;">
@XmlRootElement(namespace = NameSpaceConstant.namespace)
@XmlType(namespace = NameSpaceConstant.namespace)
public class EchoResponse {

	private String response;

	@XmlElement(namespace = NameSpaceConstant.namespace, required = true)
	public String getResponse() {
		return response;
	}

	public void setResponse(String response) {
		this.response = response;
	}
}
</pre>
<p>Finally, here&#8217;s the endpoint for this service:</p>
<pre class="brush: java; title: ;">
	@PayloadRoot(localPart = &quot;echoRequest&quot;, namespace = NameSpaceConstant.namespace)
	public EchoResponse echoServiceEndpoint(EchoRequest request) {
		EchoResponse response = new EchoResponse();
		response.setResponse(request.getEcho() + request.getEcho() + request.getEcho());
		return response;
	}
</pre>
<p>Build, deploy and run your application. If everything was configured correctly, and XSD should be generated based on your request and response classes. After generation, this XSD will be packaged in the deployment and wired to Spring-WS and its marshallers and WSDL generators. Open up the WSDL in a Soap testing tool (such as <a title="SoapUI" href="http://www.soapui.org/">SoapUI</a>) and fire up a request! If all goes well, you should get an echo of your original inputstring. As you can see, your service is completely written in Java, which means no time spent on manually generating XSD&#8217;s, WSDL&#8217;s and stuff like that. I really like this approach, it saves me a lot of time during development. Hope this helps any of you guys out there that also don&#8217;t like spending too much time on XSD&#8217;s and WSDL&#8217;s.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.walgemoed.org/2010/12/jaxb2-spring-ws/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New blog started</title>
		<link>http://www.walgemoed.org/2010/12/walgemoed-org/</link>
		<comments>http://www.walgemoed.org/2010/12/walgemoed-org/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 12:14:23 +0000</pubDate>
		<dc:creator>jwalgemoed</dc:creator>
				<category><![CDATA[walgemoed.org]]></category>

		<guid isPermaLink="false">http://www.walgemoed.org/?p=58</guid>
		<description><![CDATA[I&#8217;ve never really had the need to start blogging, but for some reason I thought it&#8217;d be a good time to start now. I hope to add posts here often that may be of interest to anyone that works with &#8230;<p class="read-more"><a href="http://www.walgemoed.org/2010/12/walgemoed-org/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve never really had the need to start blogging, but for some reason I thought it&#8217;d be a good time to start now. I hope to add posts here often that may be of interest to anyone that works with Java technology, or shares the same hobbies I have, such as music and movies.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.walgemoed.org/2010/12/walgemoed-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

