View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
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  package javax.xml.rpc.soap;
17  
18  import javax.xml.namespace.QName;
19  import javax.xml.soap.Detail;
20  
21  /**
22   * The <code>SOAPFaultException</code> exception represents a
23   * SOAP fault.
24   * <p>
25   * The message part in the SOAP fault maps to the contents of
26   * <code>faultdetail</code> element accessible through the
27   * <code>getDetail</code> method on the <code>SOAPFaultException</code>.
28   * The method <code>createDetail</code> on the
29   * <code>javax.xml.soap.SOAPFactory</code> creates an instance
30   * of the <code>javax.xml.soap.Detail</code>.
31   * <p>
32   * The <code>faultstring</code> provides a human-readable
33   * description of the SOAP fault. The <code>faultcode</code>
34   * element provides an algorithmic mapping of the SOAP fault.
35   * <p>
36   * Refer to SOAP 1.1 and WSDL 1.1 specifications for more
37   * details of the SOAP faults.
38   *
39   * @version 1.0
40   */
41  public class SOAPFaultException extends RuntimeException {
42  
43      /**
44       *  Constructor for SOAPFaultException.
45       *
46       *  @param  faultcode    <code>QName</code> for the SOAP faultcode
47       *  @param  faultstring  <code>faultstring</code> element of SOAP fault
48       *  @param  faultactor   <code>faultactor</code> element of SOAP fault
49       *  @param  detail       <code>faultdetail</code> element of SOAP fault
50       */
51      public SOAPFaultException(QName faultcode, String faultstring,
52                                String faultactor, Detail detail) {
53  
54          super(faultstring);
55  
56          this.faultcode   = faultcode;
57          this.faultstring = faultstring;
58          this.faultactor  = faultactor;
59          this.detail      = detail;
60      }
61  
62      /**
63       * Gets the <code>faultcode</code> element. The <code>faultcode</code> element provides an algorithmic
64       * mechanism for identifying the fault. SOAP defines a small set of SOAP fault codes covering
65       * basic SOAP faults.
66       * @return  QName of the faultcode element
67       */
68      public QName getFaultCode() {
69          return faultcode;
70      }
71  
72      /**
73       * Gets the <code>faultstring</code> element. The faultstring  provides a human-readable description of
74       * the SOAP fault and is not intended for algorithmic processing.
75       * @return <code>faultstring</code> element of the SOAP fault
76       */
77      public String getFaultString() {
78          return faultstring;
79      }
80  
81      /**
82       * Gets the <code>faultactor</code> element. The <code>faultactor</code>
83       * element provides information about which SOAP node on the SOAP message
84       * path caused the fault to happen. It indicates the source of the fault.
85       *
86       * @return <code>faultactor</code> element of the SOAP fault
87       */
88      public String getFaultActor() {
89          return faultactor;
90      }
91  
92      /**
93       * Gets the detail element. The detail element is intended for carrying
94       * application specific error information related to the SOAP Body.
95       *
96       * @return <code>detail</code> element of the SOAP fault
97       */
98      public Detail getDetail() {
99          return detail;
100     }
101 
102     /** Qualified name of the faultcode. */
103     private QName faultcode;
104 
105     /** The faultstring element of the SOAP fault. */
106     private String faultstring;
107 
108     /** Faultactor element of the SOAP fault. */
109     private String faultactor;
110 
111     /** Detail element of the SOAP fault. */
112     private Detail detail;
113 }