Announcement Announcement Module
Collapse
No announcement yet.
Web Service Exception Handling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web Service Exception Handling

    My apologies for the long email.

    I am new to web services but have been somewhat successful in creating a custom spring ws. I am now trying to map a business exception to the service by utilizing the SoapFaultMappingExceptionResolver.

    Currently my exceptionResolver bean is configured like so:

    <bean id="exceptionResolver"
    class="org.springframework.ws.soap.server.endpoint .SoapFaultMappingExceptionResolver">
    <property name="defaultFault" value="SERVER" />
    <property name="exceptionMappings">
    <value>com.userapp.exception.UserNotFoundException =CLIENT,User Does Not Exist</value>
    </property>
    </bean>


    Can someone tell me how to use a custom Fault-Code? When I try to do:

    <bean id="exceptionResolver"
    class="org.springframework.ws.soap.server.endpoint .SoapFaultMappingExceptionResolver">
    <property name="defaultFault" value="SERVER" />
    <property name="exceptionMappings">
    <value>com.userapp.exception.UserNotFoundException =CUSTOM_CODE,User Does Not Exist</value>
    </property>
    </bean>

    I get the following error:

    faultCode's namespaceUri cannot be empty
    at org.springframework.util.Assert.hasLength(Assert.j ava:136)
    at org.springframework.ws.soap.saaj.SaajSoap11Body.ad dFault(SaajSoap11Body.java:52)
    at org.springframework.ws.soap.server.endpoint.Abstra ctSoapFaultDefinitionExceptionResolver.resolveExce ptionInternal(AbstractSoapFaultDefinitionException Resolver.java:89)
    at org.springframework.ws.server.endpoint.AbstractEnd pointExceptionResolver.resolveException(AbstractEn dpointExceptionResolver.java:84)
    at org.springframework.ws.server.MessageDispatcher.pr ocessEndpointException(MessageDispatcher.java:311)
    at org.springframework.ws.server.MessageDispatcher.di spatch(MessageDispatcher.java:235)
    at org.springframework.ws.server.MessageDispatcher.re ceive(MessageDispatcher.java:168)
    at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:88)
    at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:57)
    at org.springframework.ws.transport.http.MessageDispa tcherServlet.doService(MessageDispatcherServlet.ja va:230)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)


    We are trying to map each of our business exceptions to a unique code so that the applications that consume our web service will be able to handle the fault appropriately (display a user friendly error based on the code returned).

    Thank you in advance for your help.

  • #2
    Hey All -
    I was able to figure it out by setting the following in exceptionResolver bean configuration:

    <bean id="exceptionResolver"
    class="org.springframework.ws.soap.server.endpoint .SoapFaultMappingExceptionResolver">
    <property name="defaultFault" value="SERVER" />
    <property name="exceptionMappings">
    <value>com.custom.exception.CustomExceptionClass={ http://custom/name/space}cns:CUSTOM_CODE,Custom Exception Thrown</value>
    </property>
    </bean>


    It's amazing what happens when you read a little documentation

    Comment

    Working...
    X