<?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>Moving the Curve &#187; General</title>
	<atom:link href="http://www.stevideter.com/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stevideter.com</link>
	<description>Technology, code, and thoughts by Stevi Deter</description>
	<lastBuildDate>Fri, 16 Apr 2010 17:01:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The Passionate Programmer</title>
		<link>http://www.stevideter.com/2010/01/07/the-passionate-programmer/</link>
		<comments>http://www.stevideter.com/2010/01/07/the-passionate-programmer/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 04:32:27 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Why I Do This]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[coding life]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[chad fowler]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[the passionate programmer]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=71</guid>
		<description><![CDATA[A few years ago, right about the time I learned my job was to be outsourced, I remember seeing a book in the bookstore titled My Job Went to India. I assumed it was a parody of sorts and decided to resist the urge to pick it up. It wasn&#8217;t until I read the introduction [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/1934356344?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1934356344"><img class="alignleft size-full wp-image-77" style="border: 0pt none; margin: 3px;" title="The Passionate Programmer" src="http://www.stevideter.com/wp-content/uploads/2010/01/passionateprogrammer.jpg" alt="The Passionate Programmer" width="106" height="160" /></a> A few years ago, right about the time I learned my job was to be outsourced, I remember seeing a book in the bookstore titled <a href="http://www.amazon.com/gp/product/0976694018?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0976694018">My Job Went to India</a>. I assumed it was a parody of sorts and decided to resist the urge to pick it up.</p>
<p>It wasn&#8217;t until I read the introduction to <a href="http://pragprog.com/titles/cfcar2/the-passionate-programmer">The Passionate Programmer</a> by Chad Fowler, that I realized it was the second edition of that same book, which had been subtitled &#8220;52 Ways to Save Your Job.&#8221; The title change is a good one, as it does a much better job of crystallizing the goal of this book.</p>
<p>The focus of <strong>The Passionate Programmer</strong> is how to have an exceptional career as a developer. It is written as several short essays on specific tips for creating a career in programming you can be passionate about, each followed by one or more specific suggestions for activities to follow through on what you&#8217;ve just read. In essence, this is <a href="http://www.amazon.com/gp/product/1580089879?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1580089879">What Color Is Your Parachute?</a> for people who already know they want to be programmers.</p>
<p>While the driving force may be passion, the topics are very pragmatic. Fowler suggests you choose your market, invest in your product, execute on your plans, and market yourself. This follows from the major thesis, that you must treat your career as a product in and of itself. The passion comes from the desire to create a great product, and do what is necessary to make that product, ultimately yourself, successful.</p>
<p>An important point that&#8217;s treated as a side note &#8211; you have to want to be a great programmer. If you find that&#8217;s not what you want, maybe you should find a career you can be passionate about.</p>
<p>Fowler provides a road map for how to create a career you love on a daily basis while moving towards a future you are excited about. The topics range from how to find enjoyment in the drudge tasks you may hate, how to keep from falling behind the technology curve, how to decide when to take career risks, and how to become truly remarkable (not just good).</p>
<p>Most of the &#8220;Act On It&#8221; tasks are highly relevant and useful. Now that I have read the entire book, I plan to review the chapters that feel the most relevant and focus on one or two of the tasks a week.</p>
<p>While much of the advice provided the The Passionate Programmer is not new, I think this is a great resource for anybody who wants to have a career as a software developer that excites and inspires. Software is a great industry, full of brilliant people and complex problems to solve. That&#8217;s why I got into it. This book provides concrete ways I can keep that passion alive.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<p>&amp;lt;a href=&#8221;http://www.amazon.com/gp/product/0976694018?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0976694018&#8243;&amp;gt;My Job Went to India: 52 Ways to Save Your Job (Pragmatic Programmers)&amp;lt;/a&amp;gt;&amp;lt;img src=&#8221;http://www.assoc-amazon.com/e/ir?t=movithecurv-20&amp;l=as2&amp;o=1&amp;a=0976694018&#8243; width=&#8221;1&#8243; height=&#8221;1&#8243; border=&#8221;0&#8243; alt=&#8221;" style=&#8221;border:none !important; margin:0px !important;&#8221; /&amp;gt;</p>
</div>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2010/01/07/the-passionate-programmer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Of ExceptionResolvers and XMLBeans</title>
		<link>http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/</link>
		<comments>http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 20:07:13 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[exception resolver]]></category>
		<category><![CDATA[soapfault]]></category>
		<category><![CDATA[spring web service]]></category>
		<category><![CDATA[xmlbeans]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=63</guid>
		<description><![CDATA[Using a custom ExceptionResolver in Spring Web Services to insert a Detail into a SoapFault.


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re using <a title="XMLBeans" href="http://xmlbeans.apache.org/" target="_blank">XMLBeans </a>with <a title="Spring Web Services" href="http://static.springframework.org/spring-ws/sites/1.5/" target="_blank">Spring Web Services</a>, and the set-up was quite easy. But the one issue I found frustrating was handling the <a title="SoapFault" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/soap/SoapFault.html" target="_blank">SoapFault</a>. The requirements in this case required including a <a title="SoapFaultDetail" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/soap/SoapFaultDetail.html" target="_blank">SoapFaultDetail</a> that contained a complex type. And while the <a title="XmlBeansMarshaller" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.html" target="_blank">XmlBeansMarshaller</a> transparently handles transforming the incoming and outgoing SOAP requests, it didn&#8217;t magically include the type defined as the fault in the WSDL within the SoapFault message.</p>
<p>Digging through the <a title="Spring Web Services tutorial" href="http://static.springframework.org/spring-ws/sites/1.5/reference/html/tutorial.html" target="_blank">tutorial</a> and some online forum postings, I finally found a solution. The <a title="AbstractSoapFaultDefinitionExceptionResovler" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/soap/server/endpoint/AbstractSoapFaultDefinitionExceptionResolver.html" target="_self">AbstractSoapFaultDefinitionExceptionResolver</a> provides a protected method void customizeFault(Object endpoint, Exception ex, SoapFault fault) that subclasses can override to modify the SoapFault before it is returned. Since this method includes the exception as a parameter, I chose to create an exception that is thrown by my endpoints that includes my desired XmlBean, already populated, so I can just use SoapFault.getResult() to marshall the information into the details.</p>
<p>For simplicity&#8217;s sake, I chose to override the existing SoapFaultMappingExceptionResolver. </p>
<p>Below, ServiceFaultDocument is an XmlObject generated by XMLBeans from my schema: </p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:schema</span> <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span>  <span style="color: #000066;">xmlns:s1</span>=<span style="color: #ff0000;">&quot;http://stevideter.com/webservice&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ServiceFault&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;s1:ServiceFault&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:complexType</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ServiceFault&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;errorCode&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;errorDescription&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:schema<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>For my Exception class:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.webservice</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.server.endpoint.annotation.FaultCode</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.server.endpoint.annotation.SoapFault</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.webservice.ServiceFaultDocument</span><span style="color: #339933;">;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * An exception that carries a ServiceFault document for inclusion in 
 * the SoapFault
 * @author stevi.deter
 *
 */</span>
@SoapFault<span style="color: #009900;">&#40;</span>faultCode <span style="color: #339933;">=</span> FaultCode.<span style="color: #006633;">SERVER</span>,faultStringOrReason<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SERVICE-ERR&quot;</span>,locale<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServiceFaultException <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> ServiceFaultDocument faultMessage<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ServiceFaultException&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s, <span style="color: #003399;">Throwable</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>s, ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s, <span style="color: #003399;">Throwable</span> ex, ServiceFaultDocument msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>s,ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setFaultMessage<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setFaultMessage<span style="color: #009900;">&#40;</span>ServiceFaultDocument msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		faultMessage <span style="color: #339933;">=</span> msg<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultDocument getFaultMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> faultMessage<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And finally my ExceptionResolver. Note that logger is ultimately inherited from AbstractEndpointExceptionResolver, which is why you don&#8217;t see it declared in the code displayed.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.webservice.soap.server.endpoint</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.Result</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.Transformer</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.TransformerException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.TransformerFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.TransformerFactoryConfigurationError</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.SoapFault</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.SoapFaultDetail</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.xml.transform.StringSource</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.webservice.ServiceFaultException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.webservice.ServiceFaultDocument</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DetailSoapFaultDefinitionExceptionResolver <span style="color: #000000; font-weight: bold;">extends</span>
		SoapFaultMappingExceptionResolver <span style="color: #009900;">&#123;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> customizeFault<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> endpoint, <span style="color: #003399;">Exception</span> ex, SoapFault fault<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ServiceFaultException msg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ex <span style="color: #000000; font-weight: bold;">instanceof</span> ServiceFaultException<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			msg <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ServiceFaultException<span style="color: #009900;">&#41;</span> ex<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			msg <span style="color: #339933;">=</span> createFaultMessage<span style="color: #009900;">&#40;</span>ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		addServiceFaultDetail<span style="color: #009900;">&#40;</span>msg, fault<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> addServiceFaultDetail<span style="color: #009900;">&#40;</span>ServiceFaultException msg, SoapFault fault<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> TransformerFactoryConfigurationError <span style="color: #009900;">&#123;</span>
		Transformer trn<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			trn <span style="color: #339933;">=</span> TransformerFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newTransformer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			SoapFaultDetail faultDetail <span style="color: #339933;">=</span> fault.<span style="color: #006633;">addFaultDetail</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Result result <span style="color: #339933;">=</span> faultDetail.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ServiceFaultDocument doc <span style="color: #339933;">=</span> msg.<span style="color: #006633;">getFaultMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>doc <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				logger.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ServiceFaultException thrown with no serviceFaultDocument!&quot;</span>,msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				trn.<span style="color: #006633;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> StringSource<span style="color: #009900;">&#40;</span>doc.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>, result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>TransformerException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			logger.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;problem with XML transform: &quot;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> ServiceFaultException createFaultMessage<span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ServiceFaultDocument faultDocument <span style="color: #339933;">=</span> ServiceFaultDocument.<span style="color: #006633;">Factory</span>.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ServiceFault fault <span style="color: #339933;">=</span> faultDocument.<span style="color: #006633;">addNewServiceFault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fault.<span style="color: #006633;">setErrorCode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SERVICE-ERR&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fault.<span style="color: #006633;">setErrorDescription</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ServiceFaultException faultMsg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ServiceFaultException<span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,e,faultDocument<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> faultMsg<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The final step is injecting my ExceptionResolver in my webservice&#8217;s servlet.xml; just showing the single bean definition here: </p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- rest of web service bean def's elided --&gt;</span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;exceptionResolver&quot;</span></span>
<span style="color: #009900;">	        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.stevideter.webservice.soap.server.endpoint.DetailSoapFaultDefinitionExceptionResolver&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;defaultFault&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;SERVER&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;exceptionMappings&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	    com.stevideter.webservice.ServiceFaultException=SERVER,FaultMsg
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now whether my Endpoints throw an Exception, the ExceptionResolver transforms it into the SoapFaultDetail, and the calling system get the results they desire:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Envelope</span> <span style="color: #000066;">xmlns:SOAP-ENV</span>=<span style="color: #ff0000;">&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Header</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Fault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;faultcode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SOAP-ENV:Server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/faultcode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;faultstring</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>FaultMsg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/faultstring<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;detail<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ServiceFault</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://stevideter.com/webservice&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;errorCode</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>SERVICE-ERR<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/errorCode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;errorDescription</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>you can't do that!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/errorDescription<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ServiceFault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/detail<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SOAP-ENV:Fault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SOAP-ENV:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SOAP-ENV:Envelope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>One issue I discovered in developing this was that we were using Saxon 8.8, a version which apparently has a bug that throws an exception on the empty namespaces in the Service Fault elements during the transform. According to the information I found, upgrading to Saxon 8.9 fixes that; I went ahead and upgraded to <a href="http://saxon.sourceforge.net/" title="Saxon XSLT and XQuery Processor">Saxon</a> 9.1.0.5 (current version as I write this) and the problem went away. Be sure to include saxon9.jar and saxon9-dom.jar if you go this route!</p>
<p>How have you used ExceptionResolvers in Web Services?</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Welcome!</title>
		<link>http://www.stevideter.com/2008/03/07/hello-world/</link>
		<comments>http://www.stevideter.com/2008/03/07/hello-world/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 07:40:58 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[welcome]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=1</guid>
		<description><![CDATA[Hello, my name is Stevi, and I am a coder. I have been coding for well over a decade. These days I work primarily in Java and C#, but have in the past have also worked in depth with JavaScript, Perl, and PHP. I plan to post various bits and pieces here. Look around, please [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Hello, my name is Stevi, and I am a coder. I have been coding for well over a decade. These days I work primarily in Java and C#, but have in the past have also worked in depth with JavaScript, Perl, and PHP.</p>
<p>I plan to post various bits and pieces here. Look around, please leave comments if you have any, and hope to provide enough interesting content to encourage you to come back.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/03/07/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
