EnvelopeVersion.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel
  5. {
  6. using System.Runtime.Serialization;
  7. using System.Xml;
  8. using System.ServiceModel.Channels;
  9. public sealed class EnvelopeVersion
  10. {
  11. string ultimateDestinationActor;
  12. string[] ultimateDestinationActorValues;
  13. string nextDestinationActorValue;
  14. string ns;
  15. XmlDictionaryString dictionaryNs;
  16. string actor;
  17. XmlDictionaryString dictionaryActor;
  18. string toStringFormat;
  19. string[] mustUnderstandActorValues;
  20. string senderFaultName;
  21. string receiverFaultName;
  22. static EnvelopeVersion soap11 =
  23. new EnvelopeVersion(
  24. "",
  25. "http://schemas.xmlsoap.org/soap/actor/next",
  26. Message11Strings.Namespace,
  27. XD.Message11Dictionary.Namespace,
  28. Message11Strings.Actor,
  29. XD.Message11Dictionary.Actor,
  30. SR.Soap11ToStringFormat,
  31. "Client",
  32. "Server");
  33. static EnvelopeVersion soap12 =
  34. new EnvelopeVersion(
  35. "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver",
  36. "http://www.w3.org/2003/05/soap-envelope/role/next",
  37. Message12Strings.Namespace,
  38. XD.Message12Dictionary.Namespace,
  39. Message12Strings.Role,
  40. XD.Message12Dictionary.Role,
  41. SR.Soap12ToStringFormat,
  42. "Sender",
  43. "Receiver");
  44. static EnvelopeVersion none = new EnvelopeVersion(
  45. null,
  46. null,
  47. MessageStrings.Namespace,
  48. XD.MessageDictionary.Namespace,
  49. null,
  50. null,
  51. SR.EnvelopeNoneToStringFormat,
  52. "Sender",
  53. "Receiver");
  54. EnvelopeVersion(string ultimateReceiverActor, string nextDestinationActorValue,
  55. string ns, XmlDictionaryString dictionaryNs, string actor, XmlDictionaryString dictionaryActor,
  56. string toStringFormat, string senderFaultName, string receiverFaultName)
  57. {
  58. this.toStringFormat = toStringFormat;
  59. this.ultimateDestinationActor = ultimateReceiverActor;
  60. this.nextDestinationActorValue = nextDestinationActorValue;
  61. this.ns = ns;
  62. this.dictionaryNs = dictionaryNs;
  63. this.actor = actor;
  64. this.dictionaryActor = dictionaryActor;
  65. this.senderFaultName = senderFaultName;
  66. this.receiverFaultName = receiverFaultName;
  67. if (ultimateReceiverActor != null)
  68. {
  69. if (ultimateReceiverActor.Length == 0)
  70. {
  71. mustUnderstandActorValues = new string[] { "", nextDestinationActorValue };
  72. ultimateDestinationActorValues = new string[] { "", nextDestinationActorValue };
  73. }
  74. else
  75. {
  76. mustUnderstandActorValues = new string[] { "", ultimateReceiverActor, nextDestinationActorValue };
  77. ultimateDestinationActorValues = new string[] { "", ultimateReceiverActor, nextDestinationActorValue };
  78. }
  79. }
  80. }
  81. internal string Actor
  82. {
  83. get { return actor; }
  84. }
  85. internal XmlDictionaryString DictionaryActor
  86. {
  87. get { return dictionaryActor; }
  88. }
  89. internal string Namespace
  90. {
  91. get { return ns; }
  92. }
  93. internal XmlDictionaryString DictionaryNamespace
  94. {
  95. get { return dictionaryNs; }
  96. }
  97. public string NextDestinationActorValue
  98. {
  99. get { return nextDestinationActorValue; }
  100. }
  101. public static EnvelopeVersion None
  102. {
  103. get { return none; }
  104. }
  105. public static EnvelopeVersion Soap11
  106. {
  107. get { return soap11; }
  108. }
  109. public static EnvelopeVersion Soap12
  110. {
  111. get { return soap12; }
  112. }
  113. internal string ReceiverFaultName
  114. {
  115. get { return receiverFaultName; }
  116. }
  117. internal string SenderFaultName
  118. {
  119. get { return senderFaultName; }
  120. }
  121. internal string[] MustUnderstandActorValues
  122. {
  123. get { return this.mustUnderstandActorValues; }
  124. }
  125. internal string UltimateDestinationActor
  126. {
  127. get { return ultimateDestinationActor; }
  128. }
  129. public string[] GetUltimateDestinationActorValues()
  130. {
  131. return (string[])this.ultimateDestinationActorValues.Clone();
  132. }
  133. internal string[] UltimateDestinationActorValues
  134. {
  135. get { return ultimateDestinationActorValues; }
  136. }
  137. internal bool IsUltimateDestinationActor(string actor)
  138. {
  139. return actor.Length == 0 || actor == this.ultimateDestinationActor || actor == this.nextDestinationActorValue;
  140. }
  141. public override string ToString()
  142. {
  143. return SR.GetString(toStringFormat, Namespace);
  144. }
  145. }
  146. }