public EndpointReferenceType CreatePullPointSubscription(Events.FilterType Filter, [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] string InitialTerminationTime, CreatePullPointSubscriptionSubscriptionPolicy SubscriptionPolicy, [System.Xml.Serialization.XmlAnyElementAttribute()] ref System.Xml.XmlElement[] Any, [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/b-2")] out System.DateTime CurrentTime, [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/b-2", IsNullable = true)] out System.Nullable <System.DateTime> TerminationTime) { //SoapFaultSubCode subCode = // new SoapFaultSubCode(new XmlQualifiedName("ResourseUnknown1", "http://www.onvif.org/ver10/error")); //SoapException exception = new SoapException("Invalid Argument", // new XmlQualifiedName("Sender", // "http://www.w3.org/2003/05/soap-envelope"), // subCode); //throw exception; Application["consumer"] = "http://127.0.0.1:8080"; Events.EndpointReferenceType endpointReferenceType = new Events.EndpointReferenceType(); endpointReferenceType.Address = new Events.AttributedURIType(); endpointReferenceType.Address.Value = string.Format("http://{0}/Events/PullPointServiceFake.asmx?param=value", HttpContext.Current.Request.Url.Authority); //endpointReferenceType.Address.Value = string.Format("http://{0}/Events/PullPointWcfService.svc?param=value", HttpContext.Current.Request.Url.Host); CurrentTime = System.DateTime.Now; TerminationTime = CurrentTime.AddSeconds(60); if (actionHeader == null) { actionHeader = new ActionHeader(); } actionHeader.Value = "http://www.onvif.org/ver10/events/wsdl/EventPortType/CreatePullPointSubscriptionResponse"; return(endpointReferenceType); }
void DoNotify1() { Events.EndpointReferenceType reference = (Events.EndpointReferenceType)Application["consumer"]; NotificationConsumerProxy.NotificationConsumerClient client = new NotificationConsumerProxy.NotificationConsumerClient(new WSHttpBinding(), new EndpointAddress(reference.Address.Value)); NotificationConsumerProxy.Notify notify = new NotificationConsumerProxy.Notify(); XmlDocument doc = new XmlDocument(); doc.LoadXml("<tt:Message UtcTime=\"2008-10-10T12:24:57.321\" xmlns:tt=\"http://www.onvif.org/ver10/schema\"><tt:Source><tt:SimpleItem Name=\"VideoSourceConfigurationToken\" Value=\"1\"/><tt:SimpleItem Name=\"VideoAnalyticsConfigurationToken\" Value=\"2\"/><tt:SimpleItem Value=\"MyImportantFence1\" Name=\"Rule\"/></tt:Source><tt:Data><tt:SimpleItem Name=\"ObjectId\" Value=\"15\" /></tt:Data></tt:Message>"); NotificationMessageHolderType notification1 = new NotificationMessageHolderType(); XmlElement message1 = doc.DocumentElement; notification1.Message = message1; notification1.ProducerReference = new EndpointReferenceType(); notification1.ProducerReference.Address = new AttributedURIType(); notification1.ProducerReference.Address.Value = HttpContext.Current.Request.Url.AbsoluteUri; notification1.Topic = new TopicExpressionType(); notification1.Topic.Dialect = ""; notify.NotificationMessage = new NotificationMessageHolderType[] { notification1 }; client.Notify(notify); }
void NotifyReceiverStateChange(string receiverToken, string state) { if (!Application.AllKeys.Contains("consumer")) { return; } NotifyParameters parameters = new NotifyParameters(); Events.EndpointReferenceType reference = (Events.EndpointReferenceType)Application["consumer"]; string address = reference.Address.Value; parameters.Address = address; string requestPattern = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\" xmlns:wstop=\"http://docs.oasis-open.org/wsn/t-1\" xmlns:wsnt=\"http://docs.oasis-open.org/wsn/b-2\" xmlns:tet=\"http://www.onvif.org/ver10/events/wsdl\" xmlns:tns1=\"http://www.onvif.org/ver10/topics\" xmlns:tt=\"http://www.onvif.org/ver10/schema\"> " + "<SOAP-ENV:Header>" + "<wsa:Action>urn:#Notify</wsa:Action>" + "<wsa:ReplyTo><wsa:Address>http://example.com/business/client1</wsa:Address></wsa:ReplyTo>" + "<wsa:MessageID>http://example.com/6B29FC40-CA47-1067-B31D-00DD010662DA http://example.com/6B29FC40-CA47-1067-B31D-00DD010662DA</wsa:MessageID>" + "</SOAP-ENV:Header>" + "<SOAP-ENV:Body>" + "<wsnt:Notify>" + "<wsnt:NotificationMessage>" + "<wsnt:Topic Dialect=\"http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet\">" + "tns1:Receiver/ChangeState" + "</wsnt:Topic>" + "<wsnt:Message>" + "<tt:Message UtcTime=\"{0}\">" + "<tt:Source>" + "<tt:SimpleItem Name=\"ReceiverToken\" Value=\"{1}\"/>" + "</tt:Source>" + "<tt:Data>" + "<tt:SimpleItem Name=\"NewState\" Value=\"{2}\"/>" + "</tt:Data>" + "</tt:Message>" + "</wsnt:Message>" + "</wsnt:NotificationMessage>" + "<tet:CurrentTime>{3}</tet:CurrentTime>" + "<tet:TerminationTime>{4}</tet:TerminationTime>" + "</wsnt:Notify>" + "</SOAP-ENV:Body>" + "</SOAP-ENV:Envelope>"; System.DateTime currentTime = System.DateTime.Now; string notificationTime = System.Xml.XmlConvert.ToString(currentTime.AddSeconds(-1), XmlDateTimeSerializationMode.Utc); string serverCurrentTime = System.Xml.XmlConvert.ToString(currentTime, XmlDateTimeSerializationMode.Utc); string terminationTime = System.Xml.XmlConvert.ToString(currentTime.AddSeconds(20), XmlDateTimeSerializationMode.Utc); string request = string.Format(requestPattern, notificationTime, receiverToken, state, serverCurrentTime, terminationTime); parameters.Request = request; System.Threading.Thread thread = new Thread(new ParameterizedThreadStart(DoNotify)); thread.Start(parameters); }
void DoNotify() { Thread.Sleep(5000); Events.EndpointReferenceType reference = (Events.EndpointReferenceType)Application["consumer"]; Notification.NotificationProvider provider = new NotificationProvider(); //string address = "http://192.168.31.142:8080//onvif_notify_server/"; string address = reference.Address.Value; provider.Notify(address); }