1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.server.endpoint;
18
19 import javax.xml.namespace.QName;
20
21 import org.springframework.util.StringUtils;
22 import org.springframework.ws.soap.server.endpoint.annotation.FaultCode;
23 import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
24
25
26
27
28
29
30
31
32 public class SoapFaultAnnotationExceptionResolver extends AbstractSoapFaultDefinitionExceptionResolver {
33
34 @Override
35 protected final SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex) {
36 SoapFault faultAnnotation = ex.getClass().getAnnotation(SoapFault.class);
37 if (faultAnnotation != null) {
38 SoapFaultDefinition definition = new SoapFaultDefinition();
39 if (faultAnnotation.faultCode() != FaultCode.CUSTOM) {
40 definition.setFaultCode(faultAnnotation.faultCode().value());
41 }
42 else if (StringUtils.hasLength(faultAnnotation.customFaultCode())) {
43 definition.setFaultCode(QName.valueOf(faultAnnotation.customFaultCode()));
44 }
45 definition.setFaultStringOrReason(faultAnnotation.faultStringOrReason());
46 definition.setLocale(StringUtils.parseLocaleString(faultAnnotation.locale()));
47 return definition;
48 }
49 else {
50 return null;
51 }
52 }
53 }