SoapHeader.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // System.Web.Services.Protocols.SoapHeader.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System.ComponentModel;
  30. using System.Xml.Serialization;
  31. using System.Xml;
  32. namespace System.Web.Services.Protocols {
  33. [SoapType (IncludeInSchema = false)]
  34. [XmlType (IncludeInSchema = false)]
  35. public abstract class SoapHeader {
  36. #region Fields
  37. string actor;
  38. bool didUnderstand;
  39. bool mustUnderstand;
  40. #if NET_2_0
  41. string role;
  42. bool relay;
  43. #endif
  44. #endregion // Fields
  45. #region Constructors
  46. protected SoapHeader ()
  47. {
  48. actor = String.Empty;
  49. didUnderstand = false;
  50. mustUnderstand = false;
  51. }
  52. internal SoapHeader (XmlElement elem)
  53. {
  54. actor = elem.GetAttribute ("actor", "http://schemas.xmlsoap.org/soap/envelope/");
  55. string me = elem.GetAttribute ("mustUnderstand", "http://schemas.xmlsoap.org/soap/envelope/");
  56. if (me != "") EncodedMustUnderstand = me;
  57. }
  58. #endregion // Constructors
  59. #region Properties
  60. [DefaultValue ("")]
  61. [SoapAttribute ("actor", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  62. [XmlAttribute ("actor", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  63. public string Actor {
  64. get { return actor; }
  65. set { actor = value; }
  66. }
  67. [SoapIgnore]
  68. [XmlIgnore]
  69. public bool DidUnderstand {
  70. get { return didUnderstand; }
  71. set { didUnderstand = value; }
  72. }
  73. [DefaultValue ("0")]
  74. [SoapAttribute ("mustUnderstand", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  75. [XmlAttribute ("mustUnderstand", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  76. public string EncodedMustUnderstand {
  77. get { return (MustUnderstand ? "1" : "0"); }
  78. set {
  79. if (value == "true" || value == "1")
  80. MustUnderstand = true;
  81. else if (value == "false" || value == "0")
  82. MustUnderstand = false;
  83. else
  84. throw new ArgumentException ();
  85. }
  86. }
  87. [SoapIgnore]
  88. [XmlIgnore]
  89. public bool MustUnderstand {
  90. get { return mustUnderstand; }
  91. set { mustUnderstand = value; }
  92. }
  93. #if NET_2_0
  94. [DefaultValue ("0")]
  95. [SoapAttribute ("mustUnderstand", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  96. [XmlAttribute ("mustUnderstand", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  97. [System.Runtime.InteropServices.ComVisible(false)]
  98. public string EncodedMustUnderstand12 {
  99. get { return (MustUnderstand ? "1" : "0"); }
  100. set {
  101. if (value == "true" || value == "1")
  102. MustUnderstand = true;
  103. else if (value == "false" || value == "0")
  104. MustUnderstand = false;
  105. else
  106. throw new ArgumentException ();
  107. }
  108. }
  109. [DefaultValue ("0")]
  110. [SoapAttribute ("relay", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  111. [XmlAttribute ("relay", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  112. [System.Runtime.InteropServices.ComVisible(false)]
  113. public string EncodedRelay
  114. {
  115. get { return (Relay ? "1" : "0"); }
  116. set {
  117. if (value == "true" || value == "1")
  118. Relay = true;
  119. else if (value == "false" || value == "0")
  120. Relay = false;
  121. else
  122. throw new ArgumentException ();
  123. }
  124. }
  125. [SoapIgnore]
  126. [XmlIgnore]
  127. [System.Runtime.InteropServices.ComVisible(false)]
  128. public bool Relay {
  129. get { return relay; }
  130. set { relay = value; }
  131. }
  132. [DefaultValue ("")]
  133. [SoapAttribute ("role", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  134. [XmlAttribute ("role", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  135. [System.Runtime.InteropServices.ComVisible(false)]
  136. public string Role {
  137. get { return role; }
  138. set { role = value; }
  139. }
  140. #endif
  141. #endregion // Properties
  142. }
  143. }