Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
8.2 KiB

  1. using System;
  2. using System.IO;
  3. using System.Web.Services;
  4. using System.Web.Services.Protocols;
  5. using System.Xml.Serialization;
  6. using UDDI.API;
  7. using UDDI;
  8. using UDDI.Diagnostics;
  9. namespace UDDI.Replication
  10. {
  11. [SoapDocumentService( ParameterStyle = SoapParameterStyle.Bare, RoutingStyle = SoapServiceRoutingStyle.RequestElement )]
  12. [WebService( Namespace=UDDI.Replication.Constants.Namespace )]
  13. public class ReplicationMessages
  14. {
  15. /// ****************************************************************
  16. /// public GetChangeRecords
  17. /// ----------------------------------------------------------------
  18. /// <summary>
  19. /// Web method for getting change records
  20. /// </summary>
  21. /// ----------------------------------------------------------------
  22. /// <param name="message">
  23. /// An instance of the get_changeRecords message
  24. /// </param>
  25. /// ----------------------------------------------------------------
  26. /// <returns>
  27. /// Returns a changeRecords element
  28. /// </returns>
  29. /// ****************************************************************
  30. ///
  31. [WebMethod, SoapDocumentMethod( Action = "\"\"", RequestElementName = "get_changeRecords" )]
  32. [UDDIExtension( transaction = true, https = true, certificate = true, messageType = "get_changeRecords" )]
  33. public ChangeRecordDetail GetChangeRecords( UDDI.Replication.GetChangeRecords message )
  34. {
  35. //
  36. // Log more information than for a usual message to help diagnose possible replication errors.
  37. //
  38. StartOperatorMessageLog( "GetChangeRecords", message );
  39. //Debug.Enter();
  40. Debug.VerifySetting( "OperatorKey" );
  41. //
  42. // Make sure the request is allowed by the communication graph.
  43. //
  44. ControlledMessage.Test( message.RequestingNode,
  45. Config.GetString( "OperatorKey" ),
  46. MessageType.GetChangeRecords );
  47. //
  48. // Retrieve the change records.
  49. //
  50. ChangeRecordDetail detail = new ChangeRecordDetail();
  51. try
  52. {
  53. detail = message.Get();
  54. EndOperatorMessageLog( "GetChangeRecords", detail );
  55. }
  56. catch( Exception e )
  57. {
  58. DispositionReport.Throw( e );
  59. EndOperatorMessageLog( "GetChangeRecords", e );
  60. }
  61. //Debug.Leave();
  62. return detail;
  63. }
  64. /// ****************************************************************
  65. /// public NotifyChangeRecordsAvailable
  66. /// ----------------------------------------------------------------
  67. /// <summary>
  68. /// </summary>
  69. /// ----------------------------------------------------------------
  70. /// <param name="message">
  71. /// An instance of the notify_changeRecordsAvailable message.
  72. /// </param>
  73. /// ****************************************************************
  74. ///
  75. [WebMethod, SoapDocumentMethod( Action = "\"\"", RequestElementName = "notify_changeRecordsAvailable" )]
  76. [UDDIExtension( transaction = true, https = true, certificate = true, messageType = "notify_changeRecordsAvailable" )]
  77. public DispositionReport NotifyChangeRecordsAvailable( UDDI.Replication.NotifyChangeRecordsAvailable message )
  78. {
  79. //
  80. // Log more information than for a usual message to help diagnose possible replication errors.
  81. //
  82. StartOperatorMessageLog( "NotifyChangeRecordsAvailable", message );
  83. //Debug.Enter();
  84. Debug.VerifySetting( "OperatorKey" );
  85. DispositionReport dr = new DispositionReport();
  86. //
  87. // Make sure the request is allowed by the communication graph.
  88. //
  89. ControlledMessage.Test( message.NotifyingNode,
  90. Config.GetString( "OperatorKey" ),
  91. MessageType.GetChangeRecords );
  92. try
  93. {
  94. message.Notify();
  95. EndOperatorMessageLog( "NotifyChangeRecordsAvailable", null );
  96. }
  97. catch( Exception e )
  98. {
  99. DispositionReport.Throw( e );
  100. EndOperatorMessageLog( "NotifyChangeRecordsAvailable", e );
  101. }
  102. //Debug.Leave();
  103. return dr;
  104. }
  105. /// ****************************************************************
  106. /// public DoPing
  107. /// ----------------------------------------------------------------
  108. /// <summary>
  109. /// </summary>
  110. /// ----------------------------------------------------------------
  111. /// <param name="message">
  112. /// An instance of the do_ping message
  113. /// </param>
  114. /// ----------------------------------------------------------------
  115. /// <returns>
  116. /// Returns an operator element with details on this operator
  117. /// node.
  118. /// </returns>
  119. /// ****************************************************************
  120. ///
  121. [WebMethod, SoapDocumentMethod( Action = "\"\"", RequestElementName = "do_ping" )]
  122. [UDDIExtension( transaction = true, https = true, certificate = true, messageType = "do_ping" )]
  123. [return: XmlElement( "operatorNodeID", Namespace=UDDI.Replication.Constants.Namespace, IsNullable=false )]
  124. public string DoPing( UDDI.Replication.DoPing message )
  125. {
  126. StartOperatorMessageLog( "DoPing", message );
  127. //Debug.Enter();
  128. //
  129. // Retrieve the change records.
  130. //
  131. string detail = null;
  132. try
  133. {
  134. detail = message.Ping();
  135. EndOperatorMessageLog( "DoPing", detail );
  136. }
  137. catch( Exception e )
  138. {
  139. DispositionReport.Throw( e );
  140. EndOperatorMessageLog( "DoPing", e );
  141. }
  142. //Debug.Leave();
  143. return detail;
  144. }
  145. /// ****************************************************************
  146. /// public GetHighWaterMarks
  147. /// ----------------------------------------------------------------
  148. /// <summary>
  149. /// </summary>
  150. /// ----------------------------------------------------------------
  151. /// <param name="message">
  152. /// An instance of the get_highWaterMarks message
  153. /// </param>
  154. /// ----------------------------------------------------------------
  155. /// <returns>
  156. /// Returns a list of high water marks seen by this node.
  157. /// </returns>
  158. /// ****************************************************************
  159. ///
  160. [WebMethod, SoapDocumentMethod( Action = "\"\"", RequestElementName = "get_highWaterMarks" )]
  161. [UDDIExtension( transaction = true, https = true, certificate = true, messageType = "get_highWaterMarks" )]
  162. public HighWaterMarkDetail GetHighWaterMarks( UDDI.Replication.GetHighWaterMarks message )
  163. {
  164. //
  165. // Log more information than for a usual message to help diagnose possible replication errors.
  166. //
  167. StartOperatorMessageLog( "GetHighWaterMarks", message );
  168. //Debug.Enter();
  169. //
  170. // Retrieve the change records.
  171. //
  172. HighWaterMarkDetail detail = null;
  173. try
  174. {
  175. detail = message.Get();
  176. EndOperatorMessageLog( "GetHighWaterMarks", detail );
  177. }
  178. catch( Exception e )
  179. {
  180. DispositionReport.Throw( e );
  181. EndOperatorMessageLog( "GetHighWaterMarks", e );
  182. }
  183. //Debug.Leave();
  184. return detail;
  185. }
  186. //
  187. // The methods below help us log more information about the replication requests. We need this information in order
  188. // to diagnose any possible problems that we have when replicating with other nodes.
  189. //
  190. private void StartOperatorMessageLog( string operationName, object message )
  191. {
  192. WriteOperatorMessage( "Started " + operationName + " request at ", message );
  193. }
  194. private void EndOperatorMessageLog( string operationName, object response )
  195. {
  196. WriteOperatorMessage( "Ended " + operationName + " request at ", response );
  197. }
  198. private void WriteOperatorMessage( string message, object payload )
  199. {
  200. UTF8EncodedStringWriter writer = new UTF8EncodedStringWriter();
  201. writer.Write( message );
  202. writer.Write( " " );
  203. writer.WriteLine( DateTime.Now );
  204. writer.WriteLine( "\r\nRaw Request:" );
  205. writer.WriteLine( "" );
  206. if( null != payload )
  207. {
  208. try
  209. {
  210. XmlSerializer serializer = new XmlSerializer( payload.GetType() );
  211. serializer.Serialize( writer, payload );
  212. }
  213. catch
  214. {
  215. writer.WriteLine( "Unable to serialize payload." );
  216. }
  217. finally
  218. {
  219. writer.Close();
  220. }
  221. }
  222. Debug.OperatorMessage( SeverityType.Info,
  223. CategoryType.Replication,
  224. OperatorMessageType.None,
  225. writer.ToString() );
  226. }
  227. }
  228. }