本文介绍了SoapFaultMappingExceptionResolver永远不会受到常规java异常的攻击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以告诉我为什么我不能用我的解析器捕获常规Java异常,所以我可以在回复响应之前对其进行转换?它永远不会受到断点的影响。如果不可能,我该怎么办?
Can anyone tell me why I cant catch a regular Java exception with my resolver so I can transform it before the response is sent back? It never gets hit with a breakpoint. If its not possible, how can I?
SoapFaultMappingExceptionResolver
public class LisSoapFaultTranslatorExceptionResolver extends SoapFaultMappingExceptionResolver {
@Override
protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {
SoapFaultDetail detail = fault.addFaultDetail();
}
}
Bean
<sws:annotation-driven />
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" />
<bean id="exceptionResolver"
class="com.openclass.adapter.ws.resolvers.LisSoapFaultTranslatorExceptionResolver">
<property name="defaultFault" value="RECEIVER,Server error">
</property>
<property name="exceptionMappings">
<value>java.lang.Exception=SERVER,FaultMsg</value>
</property>
</bean>
错误的肥皂反应
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">java.lang.NullPointerException</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
网络服务
@PayloadRoot(localPart="readCourseSectionRequest", namespace="http://www.imsglobal.org/services/lis/cmsv1p0/wsdl11/sync/imscms_v1p0")
@ResponsePayload
public ReadCourseSectionResponse readCourseSection(@RequestPayload ReadCourseSectionRequest request, MessageContext messageContext) {
// Throws error since courseService is null
ReadCourseSectionResponse openClassResponse = courseService.readCourseSection(request);
return new ReadCourseSectionResponse();
}
推荐答案
我通过添加工作了
<property name="order" value="1"></property>
到
<bean id="exceptionResolver" class="com.openclass.adapter.ws.resolvers.LisSoapFaultTranslatorExceptionResolver">
这篇关于SoapFaultMappingExceptionResolver永远不会受到常规java异常的攻击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!