spring - Adding detail in a WS SoapFault : my custom ExceptionResolver is not used -
i'm building web service using spring boot (1.2.4.release) , i'm quite new framework. especially, i'm trying customize soapfault content when exception thrown (adding "detail" tag).
i followed article : http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/
here exception:
package foo.bar.exception; import org.springframework.ws.soap.server.endpoint.annotation.faultcode; import org.springframework.ws.soap.server.endpoint.annotation.soapfault; @soapfault(faultcode = faultcode.server) public class serviceexception extends exception { private static final long serialversionuid = -1804604596179996724l; private string tempfaultdetail; public serviceexception(){ super("serviceexception"); } public serviceexception(string message) { super(message); } public serviceexception(string message, throwable cause) { super(message, cause); } public serviceexception(string message, throwable cause, string fautdetail) { super(message, cause); settempfaultdetail( fautdetail ); } public string gettempfaultdetail() { return tempfaultdetail; } public void settempfaultdetail(string tempfaultdetail) { this.tempfaultdetail = tempfaultdetail; } }
here beans.xml (i tried java configuration , annotation, i'm not sure i'm doing right, backed xml bean declaration):
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="exceptionresolver" class="foo.bar.ws.detailsoapfaultdefinitionexceptionresolver"> <property name="defaultfault" value="server" /> <property name="exceptionmappings"> <value> foo.bar.exception.serviceexception=server,faultmsg </value> </property> <property name="order" value="1" /> </bean> </beans>
and custom class wrote override soapfaultannotationexceptionresolver (at first extended soapfaultmappingexceptionresolver presented in article above) :
package foo.bar.ws; import org.apache.log4j.logger; import org.springframework.stereotype.component; import org.springframework.ws.soap.soapfault; import org.springframework.ws.soap.server.endpoint.soapfaultannotationexceptionresolver; @component public class detailsoapfaultdefinitionexceptionresolver extends soapfaultannotationexceptionresolver { public final static logger logger = logger.getlogger( detailsoapfaultdefinitionexceptionresolver.class ); public detailsoapfaultdefinitionexceptionresolver() { super(); // todo auto-generated constructor stub } @override protected void customizefault(object endpoint, exception ex, soapfault fault) { logger.debug("test ok !"); } }
but when throw serviceexception in endpoint, customizefault method of custom class never hit. , reason, class used exception handler still soapfaultannotationexceptionresolver , not mine...
does see explanation ?
already looked:
as usual, solve problem hour aftour posting online. should have done earlier !
the bean name/id tried override not right. after scanning huge amount of org.springframework.beans debug logs, found right bean name soapfaultannotationexceptionresolver
.
i managed convert configuration in java form:
package foo.bar.ws; // skipping imports... /** * ws configuration , wsdl definition */ @enablews @configuration public class webserviceconfig extends wsconfigureradapter { public final static logger logger = logger.getlogger( webserviceconfig.class ); // skipping other bean declarations... @bean(name = "soapfaultannotationexceptionresolver") public detailsoapfaultdefinitionexceptionresolver exceptionresolver( applicationcontext applicationcontext ){ detailsoapfaultdefinitionexceptionresolver exceptionresolver = new detailsoapfaultdefinitionexceptionresolver(); soapfaultdefinition soapfaultdefinition = new soapfaultdefinition(); soapfaultdefinition.setfaultcode( soapfaultdefinition.server ); exceptionresolver.setdefaultfault( soapfaultdefinition ); return exceptionresolver; } }
Comments
Post a Comment