谁能告诉我为什么我不能用我的解析器捕获一个常规的 Java 异常,这样我就可以在响应被发回之前对其进行转换?它永远不会被断点击中。如果不可能,我该怎么办?
SoapFaultMappingExceptionResolver
public class LisSoapFaultTranslatorExceptionResolver extends SoapFaultMappingExceptionResolver {
@Override
protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {
SoapFaultDetail detail = fault.addFaultDetail();
}
}
豆
<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();
}