SoapException.cs 5.8 KB

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