<?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>Java crumbs &#187; soap error detail</title>
	<atom:link href="http://blog.krecan.net/tag/soap-error-detail/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.krecan.net</link>
	<description>Short remarks from Java world</description>
	<lastBuildDate>Tue, 27 Jul 2010 13:56:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spring WS fault detail</title>
		<link>http://blog.krecan.net/2009/05/23/spring-ws-fault-detail/</link>
		<comments>http://blog.krecan.net/2009/05/23/spring-ws-fault-detail/#comments</comments>
		<pubDate>Sat, 23 May 2009 13:59:07 +0000</pubDate>
		<dc:creator>Lukáš Křečan</dc:creator>
				<category><![CDATA[Articles in English]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[soap error detail]]></category>
		<category><![CDATA[spring-ws]]></category>

		<guid isPermaLink="false">http://blog.krecan.net/?p=385</guid>
		<description><![CDATA[Spring WS project provides nice and versatile exception handling tools.  But in some scenarios predefined Exception Resolvers are not sufficient. For example if you want to provide additional error info in the soap:fault detail like in this example:


   
   
      
     [...]]]></description>
			<content:encoded><![CDATA[<p>Spring WS project provides nice and versatile <a href="http://static.springsource.org/spring-ws/sites/1.5/reference/html/server.html#server-endpoint-exception-resolver">exception handling tools</a>.  But in some scenarios predefined Exception Resolvers are not sufficient. For example if you want to provide additional error info in the soap:fault detail like in this example:</p>
<pre name="code" class="xml">
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Client</faultcode>
         <faultstring xml:lang="en">Something wrong happened</faultstring>
         <detail>
            <code>Error</code>
            <sub-code>BigTrouble</sub-code>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</pre>
<p>Fortunately it is quite easy to add similar behavior using Spring WS. You can easily extend existing <code>SoapFaultMappingExceptionResolver</code> and customize the fault (please note that <code>EndpointExeption</code> is project specific exception that provides necessary data):</p>
<pre name="code" class="java">
 public class EndpointExceptionResolver extends SoapFaultMappingExceptionResolver {
	private static final QName CODE = new QName("code");
	private static final QName SUB_CODE = new QName("sub-code");

	@Override
	protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {
		logger.warn("Exception processed ",ex);
		if (ex instanceof EndpointException) {
			EndpointException ee = (EndpointException) ex;
			SoapFaultDetail detail = fault.addFaultDetail();
			detail.addFaultDetailElement(CODE).addText(ee.getCode());
			detail.addFaultDetailElement(SUB_CODE).addText(ee.getSubCode());
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.krecan.net/2009/05/23/spring-ws-fault-detail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
