2005-06-14 Lluis Sanchez Gual <lluis@novell.com>
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Protocols / SoapException.cs
1 // \r
2 // System.Web.Services.Protocols.SoapException.cs\r
3 //\r
4 // Author:\r
5 //   Tim Coleman (tim@timcoleman.com)\r
6 //   Lluis Sanchez Gual (lluis@novell.com)\r
7 //\r
8 // Copyright (C) Tim Coleman, 2002\r
9 //\r
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31 \r
32 using System.Xml;\r
33 \r
34 namespace System.Web.Services.Protocols \r
35 {\r
36         [Serializable]\r
37         public class SoapException : SystemException \r
38         {\r
39                 #region Fields\r
40 \r
41                 public static readonly XmlQualifiedName ClientFaultCode = new XmlQualifiedName ("Client", "http://schemas.xmlsoap.org/soap/envelope/");\r
42                 public static readonly XmlQualifiedName DetailElementName = new XmlQualifiedName ("detail");\r
43                 public static readonly XmlQualifiedName MustUnderstandFaultCode = new XmlQualifiedName ("MustUnderstand", "http://schemas.xmlsoap.org/soap/envelope/");\r
44                 public static readonly XmlQualifiedName ServerFaultCode = new XmlQualifiedName ("Server", "http://schemas.xmlsoap.org/soap/envelope/");\r
45                 public static readonly XmlQualifiedName VersionMismatchFaultCode = new XmlQualifiedName ("VersionMismatch", "http://schemas.xmlsoap.org/soap/envelope/");\r
46 \r
47                 string actor;\r
48                 XmlQualifiedName code;\r
49                 XmlNode detail;\r
50                 \r
51 #if NET_2_0\r
52                 string lang;\r
53                 string role;\r
54                 SoapFaultSubcode subcode;\r
55 #endif\r
56                 #endregion\r
57 \r
58                 #region Constructors\r
59 \r
60                 public SoapException (string message, XmlQualifiedName code)\r
61                         : base (message)\r
62                 {\r
63                         this.code = code;\r
64                 }\r
65 \r
66                 public SoapException (string message, XmlQualifiedName code, Exception innerException)\r
67                         : base (message, innerException)\r
68                 {\r
69                         this.code = code;\r
70                 }\r
71 \r
72                 public SoapException (string message, XmlQualifiedName code, string actor)\r
73                         : base (message)\r
74                 {\r
75                         this.code = code;\r
76                         this.actor = actor;\r
77                 }\r
78 \r
79                 public SoapException (string message, XmlQualifiedName code, string actor, Exception innerException)\r
80                         : base (message, innerException)\r
81                 {\r
82                         this.code = code;\r
83                         this.actor = actor;\r
84                 }\r
85 \r
86                 public SoapException (string message, XmlQualifiedName code, string actor, XmlNode detail)\r
87                         : base (message)\r
88                 {\r
89                         this.code = code;\r
90                         this.actor = actor;\r
91                         this.detail = detail;\r
92                 }\r
93 \r
94                 public SoapException (string message, XmlQualifiedName code, string actor, XmlNode detail, Exception innerException)\r
95                         : base (message, innerException)\r
96                 {\r
97                         this.code = code;\r
98                         this.actor = actor;\r
99                         this.detail = detail;\r
100                 }\r
101 \r
102 #if NET_2_0\r
103                 public SoapException (string message, XmlQualifiedName code, SoapFaultSubcode subcode)\r
104                         : base (message)\r
105                 {\r
106                         this.code = code;\r
107                         this.subcode = subcode;\r
108                 }\r
109                 \r
110                 public SoapException (string message, XmlQualifiedName code, string actor, string role, XmlNode detail, SoapFaultSubcode subcode, Exception innerException)\r
111                         : base (message, innerException)\r
112                 {\r
113                         this.code = code;\r
114                         this.subcode = subcode;\r
115                         this.detail = detail;\r
116                         this.actor = actor;\r
117                         this.role = role;\r
118                 }\r
119                 \r
120                 public SoapException (string message, XmlQualifiedName code, string actor, string role, string lang, XmlNode detail, SoapFaultSubcode subcode, Exception innerException)\r
121                 {\r
122                         this.code = code;\r
123                         this.subcode = subcode;\r
124                         this.detail = detail;\r
125                         this.actor = actor;\r
126                         this.role = role;\r
127                         this.lang = lang;\r
128                 }\r
129 \r
130                 public static bool IsClientFaultCode (XmlQualifiedName code)\r
131                 {\r
132                         if (code == ClientFaultCode) return true;\r
133                         if (code == Soap12FaultCodes.SenderFaultCode) return true;\r
134                         return false;\r
135                 }\r
136 \r
137                 public static bool IsMustUnderstandFaultCode (XmlQualifiedName code)\r
138                 {\r
139                         if (code == MustUnderstandFaultCode) return true;\r
140                         if (code == Soap12FaultCodes.MustUnderstandFaultCode) return true;\r
141                         return false;\r
142                 }\r
143                                 \r
144                 public static bool IsServerFaultCode (XmlQualifiedName code)\r
145                 {\r
146                         if (code == ServerFaultCode) return true;\r
147                         if (code == Soap12FaultCodes.ReceiverFaultCode) return true;\r
148                         return false;\r
149                 }\r
150                                 \r
151                 public static bool IsVersionMismatchFaultCode (XmlQualifiedName code)\r
152                 {\r
153                         if (code == VersionMismatchFaultCode) return true;\r
154                         if (code == Soap12FaultCodes.VersionMismatchFaultCode) return true;\r
155                         return false;\r
156                 }\r
157 \r
158 #endif\r
159 \r
160                 #endregion // Constructors\r
161 \r
162                 #region Properties\r
163 \r
164                 public string Actor {\r
165                         get { return actor; }\r
166                 }\r
167 \r
168                 public XmlQualifiedName Code {\r
169                         get { return code; }\r
170                 }\r
171 \r
172                 public XmlNode Detail {\r
173                         get { return detail; }\r
174                 }\r
175 \r
176 #if NET_2_0\r
177                 [System.Runtime.InteropServices.ComVisible(false)]\r
178                 public string Lang {\r
179                         get { return lang; }\r
180                 }\r
181                 \r
182                 [System.Runtime.InteropServices.ComVisible(false)]\r
183                 public string Role {\r
184                         get { return role; }\r
185                 }\r
186                 \r
187                 [System.Runtime.InteropServices.ComVisible(false)]\r
188                 public SoapFaultSubcode Subcode {\r
189                         get { return subcode; }\r
190                 }\r
191                 \r
192                 // Same value as actor\r
193                 [System.Runtime.InteropServices.ComVisible(false)]\r
194                 public string Node {\r
195                         get { return actor; }\r
196                 }\r
197 #endif\r
198                 #endregion // Properties\r
199         }\r
200 }\r