Exemple #1
0
        private Message GetNextOutgoingMessage(Message incomingMessage, T negotiationState)
        {
            BodyWriter        firstOutgoingMessageBody;
            MessageProperties properties = null;
            Message           message;

            if (incomingMessage == null)
            {
                firstOutgoingMessageBody = this.GetFirstOutgoingMessageBody(negotiationState, out properties);
            }
            else
            {
                firstOutgoingMessageBody = this.GetNextOutgoingMessageBody(incomingMessage, negotiationState);
            }
            if (firstOutgoingMessageBody == null)
            {
                return(null);
            }
            if (incomingMessage == null)
            {
                message = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RequestSecurityTokenAction, this.MessageVersion.Addressing), firstOutgoingMessageBody);
            }
            else
            {
                message = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RequestSecurityTokenResponseAction, this.MessageVersion.Addressing), firstOutgoingMessageBody);
            }
            if (properties != null)
            {
                message.Properties.CopyProperties(properties);
            }
            this.PrepareRequest(message, firstOutgoingMessageBody as RequestSecurityToken);
            return(message);
        }
Exemple #2
0
        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);
        }
        public UnsubscribeResponse Unsubscribe([System.Xml.Serialization.XmlElementAttribute("Unsubscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Unsubscribe Unsubscribe1)
        {
            if (Application["consumer"] == null)
            {
                SoapFaultSubCode subCode =
                    new SoapFaultSubCode(new XmlQualifiedName("ResourseUnknown", "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"] = null;

            UnsubscribeResponse response = new UnsubscribeResponse();

            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeResponse";


            return(response);
        }
Exemple #4
0
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            object[] parts = null;

            if (messageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion");
            }

            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }
            if (_requestDescription.IsTypedMessage)
            {
                TypedMessageParts typedMessageParts = new TypedMessageParts(parameters[0], _requestDescription);

                // copy values from the actual field/properties
                parts = new object[typedMessageParts.Count];
                typedMessageParts.GetTypedMessageParts(parts);
            }
            else
            {
                parts = parameters;
            }
            Message msg = new OperationFormatterMessage(this, messageVersion,
                                                        _action == null ? null : ActionHeader.Create(_action, messageVersion.Addressing),
                                                        parts, null, true /*isRequest*/);

            AddPropertiesToMessage(msg, _requestDescription, parts);
            AddHeadersToMessage(msg, _requestDescription, parts, true /*isRequest*/);

            return(msg);
        }
 public void SetSynchronizationPoint()
 {
     if (actionHeader == null)
     {
         actionHeader = new ActionHeader();
     }
     actionHeader.Value = "http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/SetSynchronizationPointResponse";
 }
Exemple #6
0
 void InitHeader(WsaTextHeader header, string value)
 {
     if (header == null)
     {
         header = new ActionHeader();
     }
     header.Value = value;
 }
Exemple #7
0
 private static Message CreateReply(Message request, XmlDictionaryString action, BodyWriter body)
 {
     if (request.Headers.MessageId != null)
     {
         Message message = Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body);
         message.InitializeReply(request);
         return(message);
     }
     return(Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body));
 }
Exemple #8
0
        public void SetSynchronizationPoint()
        {
            System.Threading.Thread thread = new Thread(new ThreadStart(DoNotify));
            thread.Start();

            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/SetSynchronizationPointResponse";
        }
        protected virtual Message CreateIssueRequest(EndpointAddress target, out object requestState)
        {
            this.CommunicationObject.ThrowIfClosedOrNotOpen();
            RequestSecurityToken rst = CreateRst(target, out requestState);

            rst.RequestType = this.StandardsManager.TrustDriver.RequestTypeIssue;
            rst.MakeReadOnly();
            Message result = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.IssueAction, this.MessageVersion.Addressing), rst);

            PrepareRequest(result);
            return(result);
        }
Exemple #10
0
 static Message CreateReply(Message request, XmlDictionaryString action, BodyWriter body)
 {
     if (request.Headers.MessageId != null)
     {
         Message reply = Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body);
         reply.InitializeReply(request);
         return(reply);
     }
     else
     {
         // the message id may not be present if MapToHttp is true
         return(Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body));
     }
 }
        protected virtual Message CreateRenewRequest(EndpointAddress target, SecurityToken currentSessionToken, out object requestState)
        {
            this.CommunicationObject.ThrowIfClosedOrNotOpen();
            RequestSecurityToken rst = CreateRst(target, out requestState);

            rst.RequestType = this.StandardsManager.TrustDriver.RequestTypeRenew;
            rst.RenewTarget = this.IssuedSecurityTokenParameters.CreateKeyIdentifierClause(currentSessionToken, SecurityTokenReferenceStyle.External);
            rst.MakeReadOnly();
            Message result = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RenewAction, this.MessageVersion.Addressing), rst);
            SecurityMessageProperty supportingTokenProperty = new SecurityMessageProperty();

            supportingTokenProperty.OutgoingSupportingTokens.Add(new SupportingTokenSpecification(currentSessionToken, EmptyReadOnlyCollection <IAuthorizationPolicy> .Instance, SecurityTokenAttachmentMode.Endorsing, this.IssuedSecurityTokenParameters));
            result.Properties.Security = supportingTokenProperty;
            PrepareRequest(result);
            return(result);
        }
        protected override OutgoingMessage ProcessMessage(IncomingMessage request, ActionHeader actionHeader)
        {
            switch (actionHeader.Action)
            {
            case Schema.InvokeAction:
                return(Invoke(request));

            case Schema.GetMBeanInfoAction:
                return(GetMBeanInfo(request));

            case Schema.InstanceOfAction:
                return(IsInstanceOf(request));

            default:
                return(null);
            }
        }
Exemple #13
0
        protected override OutgoingMessage ProcessMessage(IncomingMessage request, ActionHeader actionHeader)
        {
            switch (actionHeader.Action)
            {
            case Constants.SubscribeAction:
                return(Subscribe(request));

            case Constants.UnsubscribeAction:
                return(Unsubscribe(request));

            case Constants.RenewAction:
                return(Renew(request));

            default:
                return(null);
            }
        }
Exemple #14
0
        protected virtual Message CreateRenewRequest(EndpointAddress target, SecurityToken currentSessionToken, out object requestState)
        {
            base.CommunicationObject.ThrowIfClosedOrNotOpen();
            RequestSecurityToken body = this.CreateRst(target, out requestState);

            body.RequestType = this.StandardsManager.TrustDriver.RequestTypeRenew;
            body.RenewTarget = this.IssuedSecurityTokenParameters.CreateKeyIdentifierClause(currentSessionToken, SecurityTokenReferenceStyle.External);
            body.MakeReadOnly();
            Message message = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RenewAction, this.MessageVersion.Addressing), body);
            SecurityMessageProperty property = new SecurityMessageProperty {
                OutgoingSupportingTokens = { new SupportingTokenSpecification(currentSessionToken, System.ServiceModel.Security.EmptyReadOnlyCollection <IAuthorizationPolicy> .Instance, SecurityTokenAttachmentMode.Endorsing, this.IssuedSecurityTokenParameters) }
            };

            message.Properties.Security = property;
            this.PrepareRequest(message);
            return(message);
        }
Exemple #15
0
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            object[] parts      = null;
            object   resultPart = null;

            if (messageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageVersion));
            }

            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parameters));
            }

            if (replyDescription.IsTypedMessage)
            {
                // If the response is a typed message then it must
                // me the response (as opposed to an out param).  We will
                // serialize the response in the exact same way that we
                // would serialize a bunch of outs (with no return value).

                TypedMessageParts typedMessageParts = new TypedMessageParts(result, replyDescription);

                // make a copy of the list so that we have the actual values of the field/properties
                parts = new object[typedMessageParts.Count];
                typedMessageParts.GetTypedMessageParts(parts);

                resultPart = null;
            }
            else
            {
                parts      = parameters;
                resultPart = result;
            }

            Message msg = new OperationFormatterMessage(this, messageVersion,
                                                        replyAction == null ? null : ActionHeader.Create(replyAction, messageVersion.Addressing),
                                                        parts, resultPart, false /*isRequest*/);

            AddPropertiesToMessage(msg, replyDescription, parts);
            AddHeadersToMessage(msg, replyDescription, parts, false /*isRequest*/);
            return(msg);
        }
        protected override OutgoingMessage ProcessMessage(IncomingMessage request, ActionHeader actionHeader)
        {
            switch (actionHeader.Action)
            {
            case Constants.CreateAction:
                return(Create(request));

            case Constants.GetAction:
                return(Get(request));

            case Constants.PutAction:
                return(Put(request));

            case Constants.DeleteAction:
                return(Delete(request));

            default:
                return(null);
            }
        }
Exemple #17
0
        public Capabilities GetServiceCapabilities()
        {
            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }

            // Set the value of the SoapHeader returned
            // to the client.

            actionHeader.Value = "Some strange invalid action";

            Capabilities capabilities = new Capabilities();

            capabilities.WSPausableSubscriptionManagerInterfaceSupport          = true;
            capabilities.WSPausableSubscriptionManagerInterfaceSupportSpecified = true;
            capabilities.WSPullPointSupport          = true;
            capabilities.WSPullPointSupportSpecified = true;

            return(capabilities);
        }
        private Message GetNextOutgoingMessage(Message incomingMessage, T negotiationState)
        {
            BodyWriter        nextMessageBody;
            MessageProperties nextMessageProperties = null;

            if (incomingMessage == null)
            {
                nextMessageBody = GetFirstOutgoingMessageBody(negotiationState, out nextMessageProperties);
            }
            else
            {
                nextMessageBody = GetNextOutgoingMessageBody(incomingMessage, negotiationState);
            }

            if (nextMessageBody != null)
            {
                Message nextMessage;
                if (incomingMessage == null)
                {
                    nextMessage = Message.CreateMessage(MessageVersion, ActionHeader.Create(RequestSecurityTokenAction, MessageVersion.Addressing), nextMessageBody);
                }
                else
                {
                    nextMessage = Message.CreateMessage(MessageVersion, ActionHeader.Create(RequestSecurityTokenResponseAction, MessageVersion.Addressing), nextMessageBody);
                }

                if (nextMessageProperties != null)
                {
                    nextMessage.Properties.CopyProperties(nextMessageProperties);
                }

                PrepareRequest(nextMessage, nextMessageBody as RequestSecurityToken);
                return(nextMessage);
            }
            else
            {
                return(null);
            }
        }
Exemple #19
0
        public SubscribeResponse Subscribe([System.Xml.Serialization.XmlElementAttribute("Subscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Subscribe Subscribe1)
        {
            //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"] = Subscribe1.ConsumerReference;

            SubscribeResponse response = new SubscribeResponse();

            response.CurrentTimeSpecified     = true;
            response.CurrentTime              = System.DateTime.Now;
            response.TerminationTimeSpecified = true;
            response.TerminationTime          = response.CurrentTime.AddSeconds(300);

            response.SubscriptionReference               = new Events.EndpointReferenceType();
            response.SubscriptionReference.Address       = new Events.AttributedURIType();
            response.SubscriptionReference.Address.Value = HttpContext.Current.Request.Url.AbsoluteUri + "?param=value";



            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeResponse";



            return(response);
        }
Exemple #20
0
 public OperationFormatterMessage(OperationFormatter operationFormatter, MessageVersion version, ActionHeader action,
                                  object[] parameters, object returnValue, bool isRequest)
     : base(version, action, new OperationFormatterBodyWriter(operationFormatter, version, parameters, returnValue, isRequest))
 {
     _operationFormatter = operationFormatter;
 }
Exemple #21
0
        public string[] GetEventProperties(
            [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/b-2")] out bool FixedTopicSet,
            [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/t-1")] out Events.TopicSetType TopicSet,
            [System.Xml.Serialization.XmlElementAttribute("TopicExpressionDialect", Namespace = "http://docs.oasis-open.org/wsn/b-2", DataType = "anyURI")] out string[] TopicExpressionDialect,
            [System.Xml.Serialization.XmlElementAttribute("MessageContentFilterDialect", DataType = "anyURI")] out string[] MessageContentFilterDialect,
            [System.Xml.Serialization.XmlElementAttribute("ProducerPropertiesFilterDialect", DataType = "anyURI")] out string[] ProducerPropertiesFilterDialect,
            [System.Xml.Serialization.XmlElementAttribute("MessageContentSchemaLocation", DataType = "anyURI")] out string[] MessageContentSchemaLocation,
            [System.Xml.Serialization.XmlAnyElementAttribute()] out System.Xml.XmlElement[] Any)
        {
            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://www.onvif.org/ver10/events/wsdl/EventPortType/GetEventPropertiesResponse";


            if (messageIdHeader != null)
            {
                relatesToHeader       = new RelatesToHeader();
                relatesToHeader.Value = messageIdHeader.Value;
                //relatesToHeader.Value = new System.Xml.UniqueId(Guid.Empty).ToString();
                //relatesToHeader.Value = new System.Xml.UniqueId(Guid.NewGuid()).ToString();
                //relatesToHeader.Value = "Not a GUID at all";
            }

            if (replyToHeader != null)
            {
                wsaToHeader       = new WsaToHeader();
                wsaToHeader.Value = replyToHeader.Value;
            }

            /*
             * 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;
             *
             * FixedTopicSet = true;
             * TopicSet = new TopicSetType();
             * TopicSet.Any = new XmlElement[1];
             * TopicExpressionDialect = null;
             * MessageContentFilterDialect = null;
             * MessageContentSchemaLocation = null;
             * ProducerPropertiesFilterDialect = null;
             * Any = null;
             * return null;
             */

            FixedTopicSet = true;
            TopicSet      = new Events.TopicSetType();

            string concreteTopic    = "http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete";
            string concreteSetTopic = "http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet";

            TopicExpressionDialect = new string[] { concreteTopic, concreteSetTopic };

            string mandatoryDialect = "http://www.onvif.org/ver10/tev/messageContentFilter/ItemFilter";

            MessageContentFilterDialect     = new string[] { mandatoryDialect };
            ProducerPropertiesFilterDialect = new string[] { "ProducerPropertiesFilterDialect" };
            MessageContentSchemaLocation    = new string[] { "MessageContentSchemaLocation" };

            XmlDocument doc = new XmlDocument();

            List <XmlElement> elements = new List <XmlElement>();

            foreach (string dialect in TopicExpressionDialect)
            {
                XmlElement element = doc.CreateElement("wsnt", "TopicExpressionDialect",
                                                       "http://docs.oasis-open.org/wsn/b-2");
                element.InnerText = dialect;
                elements.Add(element);
            }

            Any = elements.ToArray();

            TopicSet = new TopicSetType();

            XmlDocument doc1 = new XmlDocument();

            doc1.LoadXml("<tns1:RuleEngine xmlns:tns1=\"http://www.onvif.org/ver10/topics\" xmlns:tt=\"http://www.onvif.org/ver10/schema\" xmlns:wstop=\"http://docs.oasis-open.org/wsn/t-1\" wstop:topic=\"true\"> <tns1:LineDetector wstop:topic=\"true\"><tns1:Crossed wstop:topic=\"true\"> <tt:MessageDescription IsProperty=\"true\"><tt:Source> <tt:SimpleItem Name=\"VideoSourceConfigurationToken\" Type=\"tt:ReferenceToken\"/><tt:SimpleItem Name=\"VideoAnalyticsConfigurationToken\" Type=\"tt:ReferenceToken\"/></tt:Source> <tt:Data> <tt:SimpleItem Name=\"ObjectId\" Type=\"tt:ObjectRefType\"/></tt:Data> </tt:MessageDescription> </tns1:Crossed> </tns1:LineDetector> </tns1:RuleEngine>");

            XmlElement topic1 = doc.CreateElement("tns1:RuleEngine", "http://www.onvif.org/ver10/topics");
            //XmlAttribute attr1 = doc.CreateAttribute("wstop:topic", "http://docs.oasis-open.org/wsn/t-1");
            //attr1.Value = "true";
            //topic1.Attributes.Append(attr1);

            XmlElement   topic2 = doc.CreateElement("tns1:LineDetector", "http://www.onvif.org/ver10/topics");
            XmlAttribute attr2  = doc.CreateAttribute("wstop:topic", "http://docs.oasis-open.org/wsn/t-1");

            attr2.Value = "true";
            topic2.Attributes.Append(attr2);

            topic1.AppendChild(topic2);

            TopicSet.Any = new XmlElement[] { topic1, doc1.DocumentElement };

            return(new string[] { "http://www.onvif.org/onvif/ver10/topics/topicns.xml" });
        }
Exemple #22
0
 protected override OutgoingMessage ProcessMessage(IncomingMessage request, ActionHeader actionHeader)
 {
     return(actionHeader.Action == Constants.EnumerateAction
         ? Enumerate(request)
         : PullServer.Handle(request));
 }
        public System.DateTime PullMessages(
            [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string Timeout,
            int MessageLimit,
            [System.Xml.Serialization.XmlAnyElementAttribute()] System.Xml.XmlElement[] Any,
            out System.DateTime TerminationTime,
            [System.Xml.Serialization.XmlElementAttribute("NotificationMessage", Namespace = "http://docs.oasis-open.org/wsn/b-2")] out NotificationMessageHolderType[] NotificationMessage)
        {
            if (Timeout == "PT24H")
            {
                SoapFaultSubCode subCode =
                    new SoapFaultSubCode(new XmlQualifiedName("ShitHappens", "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;
            }

            //if (Timeout == "PT20S")
            //{
            //    PullMessagesFaultResponseType details = new PullMessagesFaultResponseType();
            //    details.MaxMessageLimit = 5;
            //    details.MaxTimeout = "PT15S";

            //    FaultException<PullMessagesFaultResponseType> exception = new FaultException<PullMessagesFaultResponseType>(details, "InvalidArg", new FaultCode("Sender", "http://www.w3.org/2003/05/soap-envelope"));
            //    throw exception;
            //}

            string varName = "PullMessagesCounter";

            int cnt = 0;

            if (Application.AllKeys.Contains(varName))
            {
                cnt = (int)Application[varName];
            }

            if (cnt % 2 == 0)
            {
                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=\"RecordingJobToken\" Value=\"1\"/></tt:Source><tt:Data><tt:SimpleItem Name=\"State\" Value=\"Idle\" /><tt:ElementItem Name=\"Information\"><tt:RecordingJobStateInformation><tt:RecordingToken>Recording1</tt:RecordingToken><tt:State>Active</tt:State></tt:RecordingJobStateInformation></tt:ElementItem></tt:Data></tt:Message>");

                NotificationMessageHolderType notification1 = CreateMessage(doc,
                                                                            "tns1",
                                                                            "http://www.onvif.org/ver10/topics",
                                                                            "RecordingConfig/JobState");

                //NotificationMessageHolderType notification2 = CreateMessage(doc, "tns1", "PropertyTopic2");

                NotificationMessage = new NotificationMessageHolderType[] { notification1 /*, notification2*/ };
            }
            else
            {
                NotificationMessage = new NotificationMessageHolderType[] { };
            }
            cnt++;
            Application[varName] = cnt;

            TerminationTime = System.DateTime.Now.AddMinutes(3);
            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesResponse";

            return(System.DateTime.Now.AddSeconds(10));
        }
 protected abstract OutgoingMessage ProcessMessage(IncomingMessage request, ActionHeader actionHeader);
 protected override OutgoingMessage ProcessMessage(IncomingMessage request, ActionHeader actionHeader)
 {
     return(actionHeader.Action == Constants.PullAction
         ? Pull(request)
         : null);
 }
Exemple #26
0
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            object[] values = null;
            if (messageVersion == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion");
            }
            if (parameters == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }
            if (this.requestDescription.IsTypedMessage)
            {
                TypedMessageParts parts = new TypedMessageParts(parameters[0], this.requestDescription);
                values = new object[parts.Count];
                parts.GetTypedMessageParts(values);
            }
            else
            {
                values = parameters;
            }
            Message message = new OperationFormatterMessage(this, messageVersion, (this.action == null) ? null : ActionHeader.Create(this.action, messageVersion.Addressing), values, null, true);

            this.AddPropertiesToMessage(message, this.requestDescription, values);
            this.AddHeadersToMessage(message, this.requestDescription, values, true);
            return(message);
        }
		public void BeforeSerialize(SoapMessage message) //ObjectOut
		{
			if(System.Environment.OSVersion.Platform != PlatformID.WinCE)
			{	
				//NOTE this only works if you handle StreamOut/In too
				//NOTE this only works on .NETfx
				TimestampHeader timestampHeader = new TimestampHeader(300);
				message.Headers.Add(timestampHeader);

				//if(EndPoint == EndPointType.Addressing)
				ActionHeader actionHeader = new ActionHeader(message.Action);
				//FromHeader fromHeader = new FromHeader(null);
				ReplyToHeader replyToHeader = new ReplyToHeader(null);
				MessageIdHeader messageIdHeader = new MessageIdHeader(null);
				ToHeader toHeader = new ToHeader(message.Url);
				message.Headers.Add(actionHeader);
				//message.Headers.Add(fromHeader);
				message.Headers.Add(replyToHeader);
				message.Headers.Add(messageIdHeader);
				message.Headers.Add(toHeader);
				//else //routing
				//pathHeader pHeader = new pathHeader(message.Action, message.Url, null);
				//message.Headers.Add(pHeader);
			}
			return;
		}
		public void BeforeSerialize(SoapMessage message) //ObjectOut
		{
			if(onClientOrServer == OnClientOrServer.Unknown)
				onClientOrServer = OnClientOrServer.Client;
			if(System.Environment.OSVersion.Platform != PlatformID.WinCE)
			{	
				//NOTE this only works if you handle StreamOut/In too
				//NOTE this only works on .NETfx
				//TimestampHeader timestampHeader = new TimestampHeader(300);
				//message.Headers.Add(timestampHeader);
				if(onClientOrServer == OnClientOrServer.Server)
				{
					ActionHeader actionHeader = new ActionHeader(message.Action + "Response");
					//else check what the inAction is
					RelatesToHeader relatesToHeader = null;
					if(inMessageId != null)
						relatesToHeader = new RelatesToHeader(inMessageId);
					ToHeader toHeader = null;
					if(inReplyTo != null)
						toHeader = new ToHeader(inReplyTo);
					//TODO ReferenceProperties
					message.Headers.Add(actionHeader);
					if(relatesToHeader != null)
						message.Headers.Add(relatesToHeader);
					if(toHeader != null)
						message.Headers.Add(toHeader);
				}
				else
				{
					//if(EndPoint == EndPointType.Addressing)
					ActionHeader actionHeader = new ActionHeader(message.Action);
					FromHeader fromHeader = new FromHeader(null);
					MessageIdHeader messageIdHeader = new MessageIdHeader(null);
					ToHeader toHeader = new ToHeader(message.Url);
					//TODO Subscription would need a ReplyTo header for asynch web services
					//ReplyToHeader replyToHeader = new ReplyToHeader("http://tempuri.org/RespondToClientCall/");
					ReplyToHeader replyToHeader = new ReplyToHeader(message.Url); //just respond normally?
					message.Headers.Add(replyToHeader);
					message.Headers.Add(actionHeader);
					message.Headers.Add(fromHeader);
					message.Headers.Add(messageIdHeader);
					message.Headers.Add(toHeader);
				}
				//else //routing
				//pathHeader pHeader = new pathHeader(message.Action, message.Url, null);
				//message.Headers.Add(pHeader);
			}
			return;
		}