code_junkie

Does WCF support WS-Eventing?

Nov 11th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. Subscribe s = new Subscribe();
  2. (s.Delivery = new DeliveryType()).Mode = "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push";
  3.  
  4. XmlDocument doc = new XmlDocument();
  5. using (XmlWriter writer = doc.CreateNavigator().AppendChild())
  6. {
  7. EndpointReferenceType notifyTo = new EndpointReferenceType();
  8.  
  9. (notifyTo.Address = new AttributedURI()).Value = callbackEndpoint.Uri.AbsoluteUri;
  10.  
  11. XmlRootAttribute notifyToElem = new XmlRootAttribute("NotifyTo");
  12. notifyToElem.Namespace = "http://schemas.xmlsoap.org/ws/2004/08/eventing";
  13.  
  14. XmlDocument doc2 = new XmlDocument();
  15. using (XmlWriter writer2 = doc2.CreateNavigator().AppendChild())
  16. {
  17. XmlRootAttribute ReferenceElement = new XmlRootAttribute("ReferenceElement");
  18. foreach(AddressHeader h in callbackEndpoint.Headers)
  19. {
  20. h.WriteAddressHeader(writer2);
  21. }
  22.  
  23. writer2.Close();
  24. notifyTo.ReferenceParameters = new ReferenceParametersType();
  25. notifyTo.ReferenceParameters.Any = notifyTo.ReferenceParameters.Any = doc2.ChildNodes.Cast<XmlElement>().ToArray<XmlElement>();
  26. }
  27.  
  28. new XmlSerializer(notifyTo.GetType(), notifyToElem).Serialize(writer, notifyTo);
  29. }
  30.  
  31. (s.Delivery.Any = new XmlElement[1])[0] = doc.DocumentElement;
  32. (s.Filter = new FilterType()).Dialect = "http://schemas.xmlsoap.org/ws/2006/02/devprof/Action";
  33. (s.Filter.Any = new System.Xml.XmlNode[1])[0] = new System.Xml.XmlDocument().CreateTextNode("http://www.teco.edu/SensorValues/SensorValuesEventOut");
  34.  
  35. SubscribeResponse subscription;
  36. try
  37. {
  38. Console.WriteLine("Subscribing to the event...");
  39. //Console.ReadLine();
  40. subscription = eventSource.SubscribeOp(s);
  41. }
Add Comment
Please, Sign In to add comment