01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.soap.client;
18:
19: import javax.xml.namespace.QName;
20:
21: import org.springframework.ws.client.WebServiceFaultException;
22: import org.springframework.ws.soap.SoapBody;
23: import org.springframework.ws.soap.SoapFault;
24: import org.springframework.ws.soap.SoapMessage;
25:
26: /**
27: * Thrown by <code>SoapFaultMessageResolver</code> when the response message has a fault.
28: *
29: * @author Arjen Poutsma
30: * @since 1.0.0
31: */
32: public class SoapFaultClientException extends WebServiceFaultException {
33:
34: private final SoapFault soapFault;
35:
36: /**
37: * Create a new instance of the <code>SoapFaultClientException</code> class.
38: *
39: * @param faultMessage the fault message
40: */
41: public SoapFaultClientException(SoapMessage faultMessage) {
42: super (faultMessage);
43: SoapBody body = faultMessage.getSoapBody();
44: soapFault = body != null ? body.getFault() : null;
45: }
46:
47: /** Returns the {@link SoapFault}. */
48: public SoapFault getSoapFault() {
49: return soapFault;
50: }
51:
52: /** Returns the fault code. */
53: public QName getFaultCode() {
54: return soapFault != null ? soapFault.getFaultCode() : null;
55: }
56:
57: /**
58: * Returns the fault string or reason. For SOAP 1.1, this returns the fault string. For SOAP 1.2, this returns the
59: * fault reason for the default locale.
60: * <p/>
61: * Note that this message returns the same as {@link #getMessage()}.
62: */
63: public String getFaultStringOrReason() {
64: return soapFault != null ? soapFault.getFaultStringOrReason()
65: : null;
66: }
67:
68: }
|