SoapHeader.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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", WebServiceHelper.SoapEnvelopeNamespace);
  55. string me = elem.GetAttribute ("mustUnderstand", WebServiceHelper.SoapEnvelopeNamespace);
  56. if (me != "") EncodedMustUnderstand = me;
  57. #if NET_2_0
  58. role = elem.GetAttribute ("role", WebServiceHelper.Soap12EnvelopeNamespace);
  59. me = elem.GetAttribute ("mustUnderstand", WebServiceHelper.Soap12EnvelopeNamespace);
  60. if (me != "") EncodedMustUnderstand12 = me;
  61. #endif
  62. }
  63. #endregion // Constructors
  64. #region Properties
  65. [DefaultValue ("")]
  66. [SoapAttribute ("actor", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  67. [XmlAttribute ("actor", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  68. public string Actor {
  69. get { return actor; }
  70. set { actor = value; }
  71. }
  72. [SoapIgnore]
  73. [XmlIgnore]
  74. public bool DidUnderstand {
  75. get { return didUnderstand; }
  76. set { didUnderstand = value; }
  77. }
  78. [DefaultValue ("0")]
  79. [SoapAttribute ("mustUnderstand", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  80. [XmlAttribute ("mustUnderstand", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
  81. public string EncodedMustUnderstand {
  82. get { return (MustUnderstand ? "1" : "0"); }
  83. set {
  84. if (value == "true" || value == "1")
  85. MustUnderstand = true;
  86. else if (value == "false" || value == "0")
  87. MustUnderstand = false;
  88. else
  89. throw new ArgumentException ();
  90. }
  91. }
  92. [SoapIgnore]
  93. [XmlIgnore]
  94. public bool MustUnderstand {
  95. get { return mustUnderstand; }
  96. set { mustUnderstand = value; }
  97. }
  98. #if NET_2_0
  99. [DefaultValue ("0")]
  100. [SoapAttribute ("mustUnderstand", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  101. [XmlAttribute ("mustUnderstand", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  102. [System.Runtime.InteropServices.ComVisible(false)]
  103. public string EncodedMustUnderstand12 {
  104. get { return (MustUnderstand ? "1" : "0"); }
  105. set {
  106. if (value == "true" || value == "1")
  107. MustUnderstand = true;
  108. else if (value == "false" || value == "0")
  109. MustUnderstand = false;
  110. else
  111. throw new ArgumentException ();
  112. }
  113. }
  114. [DefaultValue ("0")]
  115. [SoapAttribute ("relay", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  116. [XmlAttribute ("relay", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  117. [System.Runtime.InteropServices.ComVisible(false)]
  118. public string EncodedRelay
  119. {
  120. get { return (Relay ? "1" : "0"); }
  121. set {
  122. if (value == "true" || value == "1")
  123. Relay = true;
  124. else if (value == "false" || value == "0")
  125. Relay = false;
  126. else
  127. throw new ArgumentException ();
  128. }
  129. }
  130. [SoapIgnore]
  131. [XmlIgnore]
  132. [System.Runtime.InteropServices.ComVisible(false)]
  133. public bool Relay {
  134. get { return relay; }
  135. set { relay = value; }
  136. }
  137. [DefaultValue ("")]
  138. [SoapAttribute ("role", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  139. [XmlAttribute ("role", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
  140. [System.Runtime.InteropServices.ComVisible(false)]
  141. public string Role {
  142. get { return role; }
  143. set { role = value; }
  144. }
  145. #endif
  146. #endregion // Properties
  147. }
  148. }