2 // System.Web.Services.Protocols.SoapException.cs
5 // Tim Coleman (tim@timcoleman.com)
6 // Lluis Sanchez Gual (lluis@novell.com)
8 // Copyright (C) Tim Coleman, 2002
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:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
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.
33 using System.Runtime.Serialization;
36 namespace System.Web.Services.Protocols
41 public class SoapException : SystemException
45 public static readonly XmlQualifiedName ClientFaultCode = new XmlQualifiedName ("Client", "http://schemas.xmlsoap.org/soap/envelope/");
46 public static readonly XmlQualifiedName DetailElementName = new XmlQualifiedName ("detail");
47 public static readonly XmlQualifiedName MustUnderstandFaultCode = new XmlQualifiedName ("MustUnderstand", "http://schemas.xmlsoap.org/soap/envelope/");
48 public static readonly XmlQualifiedName ServerFaultCode = new XmlQualifiedName ("Server", "http://schemas.xmlsoap.org/soap/envelope/");
49 public static readonly XmlQualifiedName VersionMismatchFaultCode = new XmlQualifiedName ("VersionMismatch", "http://schemas.xmlsoap.org/soap/envelope/");
52 XmlQualifiedName code;
58 SoapFaultSubCode subcode;
65 public SoapException ()
66 : this ("SOAP error", XmlQualifiedName.Empty)
71 public SoapException (string message, XmlQualifiedName code)
77 public SoapException (string message, XmlQualifiedName code, Exception innerException)
78 : base (message, innerException)
83 public SoapException (string message, XmlQualifiedName code, string actor)
90 public SoapException (string message, XmlQualifiedName code, string actor, Exception innerException)
91 : base (message, innerException)
97 public SoapException (string message, XmlQualifiedName code, string actor, XmlNode detail)
102 this.detail = detail;
105 public SoapException (string message, XmlQualifiedName code, string actor, XmlNode detail, Exception innerException)
106 : base (message, innerException)
110 this.detail = detail;
114 public SoapException (string message, XmlQualifiedName code, SoapFaultSubCode subcode)
118 this.subcode = subcode;
121 public SoapException (string message, XmlQualifiedName code, string actor, string role, XmlNode detail, SoapFaultSubCode subcode, Exception innerException)
122 : base (message, innerException)
125 this.subcode = subcode;
126 this.detail = detail;
131 public SoapException (string message, XmlQualifiedName code, string actor, string role, string lang, XmlNode detail, SoapFaultSubCode subcode, Exception innerException)
132 : this (message, code, actor, role, detail, subcode, innerException)
138 protected SoapException (SerializationInfo info, StreamingContext context)
139 : base (info, context)
141 actor = info.GetString ("actor");
142 code = (XmlQualifiedName) info.GetValue ("code", typeof (XmlQualifiedName));
143 detail = new XmlDocument ().ReadNode (
144 XmlReader.Create (new StringReader (info.GetString ("detailString"))));
145 lang = info.GetString ("lang");
146 role = info.GetString ("role");
147 subcode = (SoapFaultSubCode) info.GetValue ("subcode", typeof (SoapFaultSubCode));
150 public override void GetObjectData (SerializationInfo info, StreamingContext context)
152 base.GetObjectData (info, context);
153 info.AddValue ("actor", actor);
154 info.AddValue ("code", code);
155 info.AddValue ("detailString", detail.OuterXml);
156 info.AddValue ("lang", lang);
157 info.AddValue ("role", role);
158 info.AddValue ("subcode", subcode);
162 public static bool IsClientFaultCode (XmlQualifiedName code)
164 if (code == ClientFaultCode) return true;
165 if (code == Soap12FaultCodes.SenderFaultCode) return true;
169 public static bool IsMustUnderstandFaultCode (XmlQualifiedName code)
171 if (code == MustUnderstandFaultCode) return true;
172 if (code == Soap12FaultCodes.MustUnderstandFaultCode) return true;
176 public static bool IsServerFaultCode (XmlQualifiedName code)
178 if (code == ServerFaultCode) return true;
179 if (code == Soap12FaultCodes.ReceiverFaultCode) return true;
183 public static bool IsVersionMismatchFaultCode (XmlQualifiedName code)
185 if (code == VersionMismatchFaultCode) return true;
186 if (code == Soap12FaultCodes.VersionMismatchFaultCode) return true;
192 #endregion // Constructors
196 public string Actor {
197 get { return actor; }
200 public XmlQualifiedName Code {
204 public XmlNode Detail {
205 get { return detail; }
209 [System.Runtime.InteropServices.ComVisible(false)]
214 [System.Runtime.InteropServices.ComVisible(false)]
219 [System.Runtime.InteropServices.ComVisible(false)]
220 public SoapFaultSubCode SubCode {
221 get { return subcode; }
224 // Same value as actor
225 [System.Runtime.InteropServices.ComVisible(false)]
227 get { return actor; }
230 #endregion // Properties