SoapException.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. [Serializable]
  34. public class SoapException : SystemException
  35. {
  36. #region Fields
  37. public static readonly XmlQualifiedName ClientFaultCode = new XmlQualifiedName ("Client", "http://schemas.xmlsoap.org/soap/envelope/");
  38. public static readonly XmlQualifiedName DetailElementName = new XmlQualifiedName ("detail");
  39. public static readonly XmlQualifiedName MustUnderstandFaultCode = new XmlQualifiedName ("MustUnderstand", "http://schemas.xmlsoap.org/soap/envelope/");
  40. public static readonly XmlQualifiedName ServerFaultCode = new XmlQualifiedName ("Server", "http://schemas.xmlsoap.org/soap/envelope/");
  41. public static readonly XmlQualifiedName VersionMismatchFaultCode = new XmlQualifiedName ("VersionMismatch", "http://schemas.xmlsoap.org/soap/envelope/");
  42. string actor;
  43. XmlQualifiedName code;
  44. XmlNode detail;
  45. #if NET_2_0
  46. string lang;
  47. string role;
  48. SoapFaultSubcode subcode;
  49. #endif
  50. #endregion
  51. #region Constructors
  52. public SoapException (string message, XmlQualifiedName code)
  53. : base (message)
  54. {
  55. this.code = code;
  56. }
  57. public SoapException (string message, XmlQualifiedName code, Exception innerException)
  58. : base (message, innerException)
  59. {
  60. this.code = code;
  61. }
  62. public SoapException (string message, XmlQualifiedName code, string actor)
  63. : base (message)
  64. {
  65. this.code = code;
  66. this.actor = actor;
  67. }
  68. public SoapException (string message, XmlQualifiedName code, string actor, Exception innerException)
  69. : base (message, innerException)
  70. {
  71. this.code = code;
  72. this.actor = actor;
  73. }
  74. public SoapException (string message, XmlQualifiedName code, string actor, XmlNode detail)
  75. : base (message)
  76. {
  77. this.code = code;
  78. this.actor = actor;
  79. this.detail = detail;
  80. }
  81. public SoapException (string message, XmlQualifiedName code, string actor, XmlNode detail, Exception innerException)
  82. : base (message, innerException)
  83. {
  84. this.code = code;
  85. this.actor = actor;
  86. this.detail = detail;
  87. }
  88. #if NET_2_0
  89. public SoapException (string message, XmlQualifiedName code, SoapFaultSubcode subcode)
  90. : base (message)
  91. {
  92. this.code = code;
  93. this.subcode = subcode;
  94. }
  95. public SoapException (string message, XmlQualifiedName code, string actor, string role, XmlNode detail, SoapFaultSubcode subcode, Exception innerException)
  96. : base (message, innerException)
  97. {
  98. this.code = code;
  99. this.subcode = subcode;
  100. this.detail = detail;
  101. this.actor = actor;
  102. this.role = role;
  103. }
  104. public SoapException (string message, XmlQualifiedName code, string actor, string role, string lang, XmlNode detail, SoapFaultSubcode subcode, Exception innerException)
  105. {
  106. this.code = code;
  107. this.subcode = subcode;
  108. this.detail = detail;
  109. this.actor = actor;
  110. this.role = role;
  111. this.lang = lang;
  112. }
  113. public static bool IsClientFaultCode (XmlQualifiedName code)
  114. {
  115. if (code == ClientFaultCode) return true;
  116. if (code == Soap12FaultCodes.SenderFaultCode) return true;
  117. return false;
  118. }
  119. public static bool IsMustUnderstandFaultCode (XmlQualifiedName code)
  120. {
  121. if (code == MustUnderstandFaultCode) return true;
  122. if (code == Soap12FaultCodes.MustUnderstandFaultCode) return true;
  123. return false;
  124. }
  125. public static bool IsServerFaultCode (XmlQualifiedName code)
  126. {
  127. if (code == ServerFaultCode) return true;
  128. if (code == Soap12FaultCodes.ReceiverFaultCode) return true;
  129. return false;
  130. }
  131. public static bool IsVersionMismatchFaultCode (XmlQualifiedName code)
  132. {
  133. if (code == VersionMismatchFaultCode) return true;
  134. if (code == Soap12FaultCodes.VersionMismatchFaultCode) return true;
  135. return false;
  136. }
  137. #endif
  138. #endregion // Constructors
  139. #region Properties
  140. public string Actor {
  141. get { return actor; }
  142. }
  143. public XmlQualifiedName Code {
  144. get { return code; }
  145. }
  146. public XmlNode Detail {
  147. get { return detail; }
  148. }
  149. #if NET_2_0
  150. [System.Runtime.InteropServices.ComVisible(false)]
  151. public string Lang {
  152. get { return lang; }
  153. }
  154. [System.Runtime.InteropServices.ComVisible(false)]
  155. public string Role {
  156. get { return role; }
  157. }
  158. [System.Runtime.InteropServices.ComVisible(false)]
  159. public SoapFaultSubcode Subcode {
  160. get { return subcode; }
  161. }
  162. // Same value as actor
  163. [System.Runtime.InteropServices.ComVisible(false)]
  164. public string Node {
  165. get { return actor; }
  166. }
  167. #endif
  168. #endregion // Properties
  169. }
  170. }