Esempio n. 1
0
        void VerifySeekTopics(TopicSetType topicSet)
        {
            TopicSetHelper    Helper    = new TopicSetHelper(this, topicSet, false);
            List <XmlElement> topicList = Helper.FindTopics();

            foreach (XmlElement topicElement in topicList)
            {
                if (!TopicInfo.TopicsMatch(TopicInfo.ConstructTopicInfo(topicElement), BeginTopic))
                {
                    continue;
                }
                XmlElement messageDescription = topicElement.GetMessageDescription();
                if (messageDescription != null)
                {
                    bool isProperty = false;
                    // check that it is a property
                    if (messageDescription.HasAttribute(OnvifMessage.ISPROPERTY))
                    {
                        isProperty = XmlConvert.ToBoolean(messageDescription.Attributes[OnvifMessage.ISPROPERTY].Value);
                    }
                    Assert(!isProperty,
                           "Topic should not be property topic",
                           "Check " + BeginPath + " topic type");
                    return;
                }
            }
            Assert(false,
                   "Topic missed",
                   "Check " + BeginPath + " topic present");
        }
            public static Model Create(
                bool includeAnalitycs,
                bool isPtzStatusSupported,
                bool includePtzStatus,
                bool isPtzPositionSupported,
                bool includePtzPosition,
                bool includeEvents,
                string[] messageContentFilterDialects,
                string[] topicExpressionDialects,
                bool isFixedTopicSet,
                TopicSetType topicSet,
                TopicExpressionFilter[] topicExpressionFilters,
                MessageContentFilter[] messageContentFilters
                )
            {
                var _this = new Model();

                _this.isPtzStatusSupported         = isPtzStatusSupported;
                _this.isPtzPositionSupported       = isPtzPositionSupported;
                _this.messageContentFilterDialects = messageContentFilterDialects;
                _this.topicExpressionDialects      = topicExpressionDialects;
                _this.isFixedTopicSet               = isFixedTopicSet;
                _this.topicSet                      = topicSet;
                _this.origin.includeAnalitycs       = includeAnalitycs;
                _this.origin.includePtzStatus       = includePtzStatus;
                _this.origin.includePtzPosition     = includePtzPosition;
                _this.origin.includeEvents          = includeEvents;
                _this.origin.topicExpressionFilters = topicExpressionFilters;
                _this.origin.messageContentFilters  = messageContentFilters;
                _this.RevertChanges();

                return(_this);
            }
        public override 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 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)
        {
            SoapHeaderProcessing(unknownHeaders);

            ConfStorageLoad();
            EventServerLoad();

            string[] res = new string[1];

            res[0]                          = @"http://www.onvif.org/onvif/ver10/topics/topicns.xml";
            FixedTopicSet                   = true;
            TopicSet                        = new TopicSetType();
            TopicExpressionDialect          = new string[2];
            TopicExpressionDialect[0]       = @"http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet";
            TopicExpressionDialect[1]       = @"http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete";
            MessageContentFilterDialect     = new string[1];
            MessageContentFilterDialect[0]  = @"http://www.onvif.org/ver10/tev/messageContentFilter/ItemFilter";
            MessageContentSchemaLocation    = new string[1];
            MessageContentSchemaLocation[0] = @"http://www.onvif.org/ver10/schema/onvif.xsd";
            ProducerPropertiesFilterDialect = null;
            Any = null;

            TopicSet.Any = EventServer.TopicSet;

            EventServerSave();
            ConfStorageSave();

            actionHeader.actionValue = "http://www.onvif.org/ver10/events/wsdl/EventPortType/GetEventPropertiesResponse";

            return(res);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets TopicSet
        /// </summary>
        /// <returns></returns>
        protected TopicSetType GetTopicSet()
        {
            // service client to get event information
            EnsureEventPortTypeClientCreated();

            string[] response = null;

            bool         fixedTopicSet = false;
            TopicSetType topicSet      = null;

            string[]     topicExpressionDialect          = null;
            string[]     messageContentFilterDialect     = null;
            string[]     producerPropertiesFilterDialect = null;
            string[]     messageContentSchemaLocation    = null;
            XmlElement[] any = null;

            // query properties
            response = GetEventProperties(out fixedTopicSet,
                                          out topicSet,
                                          out topicExpressionDialect,
                                          out messageContentFilterDialect,
                                          out producerPropertiesFilterDialect,
                                          out messageContentSchemaLocation,
                                          out any);

            return(topicSet);
        }
        protected TopicSetType GetTopicSet()
        {
            TopicSetType topicSet = null;

            if (null != eventService)
            {
                RunStep(() =>
                {
                    bool fixedTopicSet = false;
                    string[] topicExpressionDialect          = null;
                    string[] messageContentFilterDialect     = null;
                    string[] producerPropertiesFilterDialect = null;
                    string[] messageContentSchemaLocation    = null;
                    XmlElement[] any = null;

                    eventService.GetEventProperties(out fixedTopicSet,
                                                    out topicSet,
                                                    out topicExpressionDialect,
                                                    out messageContentFilterDialect,
                                                    out producerPropertiesFilterDialect,
                                                    out messageContentSchemaLocation,
                                                    out any);
                },
                        "Get Event Properties");
            }


            return(topicSet);
        }
 public void RevertChanges()
 {
     this.current.triggers  = this.origin.triggers;
     this.current.selection = this.origin.selection;
     this.current.actions   = this.origin.actions;
     this.current.topicSet  = this.origin.topicSet;
 }
        private static IList <String> GetConcreteSetTopics(TopicSetType topicSet)
        {
            var topics = new List <string>();
            var roots  = topicSet.Any ?? new XmlElement[0];

            foreach (var root in roots)
            {
                string path = root.Name;
                ParseConcreteSetTopicElement(root, path, topics);
            }
            return(topics);
        }
Esempio n. 8
0
 public ExpressionArguments(string[] messageContentFilterDialects,
                            MessageContentFilter[] messageContentFilters,
                            string[] topicExpressionDialects,
                            TopicExpressionFilter[] topicExpressionFilters,
                            TopicSetType topicSet, Dictionary <string, string> namespaces)
 {
     this.messageContentFilterDialects = messageContentFilterDialects;
     this.messageContentFilters        = messageContentFilters;
     this.topicExpressionDialects      = topicExpressionDialects;
     this.topicExpressionFilters       = topicExpressionFilters;
     this.topicSet   = topicSet;
     this.namespaces = namespaces;
 }
            public static Model Create(
                ActionTrigger trigger,
                Action1[] actions,
                TopicSetType topicSet
                )
            {
                var _this = new Model();

                _this.origin.trigger  = trigger;
                _this.origin.actions  = actions;
                _this.origin.topicSet = topicSet;
                _this.RevertChanges();

                return(_this);
            }
Esempio n. 10
0
        void ValidateTopicSet(TopicSetType topicSet)
        {
            Assert(topicSet != null, "TopicSet is null", "Check that the TopicSet returned is not null");
            Assert(topicSet.Any != null, "TopicSet content is null", "Check that the DUT returned not empty TopicSet");

            foreach (XmlElement element in topicSet.Any)
            {
                if (FindTopic(element))
                {
                    return;
                }
            }

            Assert(false, "No topics found!", "Check if response contains at least one topic in TopicSet");
        }
Esempio n. 11
0
        /// <summary>
        /// Gets event properties. Creates client, if necessary.
        /// </summary>
        /// <param name="FixedTopicSet"></param>
        /// <param name="TopicSet"></param>
        /// <param name="TopicExpressionDialect"></param>
        /// <param name="MessageContentFilterDialect"></param>
        /// <param name="ProducerPropertiesFilterDialect"></param>
        /// <param name="MessageContentSchemaLocation"></param>
        /// <param name="Any"></param>
        /// <returns></returns>
        /// <remarks>As this method uses EventPortType client, the client can be created without additional data.</remarks>
        protected string[] GetEventProperties(out bool FixedTopicSet,
                                              out TopicSetType TopicSet,
                                              out string[] TopicExpressionDialect,
                                              out string[] MessageContentFilterDialect,
                                              out string[] ProducerPropertiesFilterDialect,
                                              out string[] MessageContentSchemaLocation,
                                              out XmlElement[] Any)
        {
            EnsureEventPortTypeClientCreated();

            string[] response = null;

            bool         fixedTopicSetCopy = false;
            TopicSetType topicSetCopy      = null;

            string[]     topicExpressionDialectCopy          = null;
            string[]     messageContentFilterDialectCopy     = null;
            string[]     producerPropertiesFilterDialectCopy = null;
            string[]     messageContentSchemaLocationCopy    = null;
            XmlElement[] anyCopy = null;

            RunStep(() =>
            {
                response = _eventPortTypeClient.GetEventProperties(out fixedTopicSetCopy,
                                                                   out topicSetCopy,
                                                                   out topicExpressionDialectCopy,
                                                                   out messageContentFilterDialectCopy,
                                                                   out producerPropertiesFilterDialectCopy,
                                                                   out messageContentSchemaLocationCopy,
                                                                   out anyCopy);
            },
                    "Get Event Properties");

            FixedTopicSet                   = fixedTopicSetCopy;
            TopicSet                        = topicSetCopy;
            TopicExpressionDialect          = topicExpressionDialectCopy;
            MessageContentFilterDialect     = messageContentFilterDialectCopy;
            ProducerPropertiesFilterDialect = producerPropertiesFilterDialectCopy;
            MessageContentSchemaLocation    = messageContentSchemaLocationCopy;
            Any = anyCopy;

            DoRequestDelay();

            return(response);
        }
Esempio n. 12
0
        /// <summary>
        /// Gets TopicSet
        /// </summary>
        /// <returns></returns>
        protected TopicSetType GetTopicSet()
        {
            string[] response = null;

            bool         fixedTopicSet = false;
            TopicSetType topicSet      = null;

            string[]     topicExpressionDialect          = null;
            string[]     messageContentFilterDialect     = null;
            string[]     producerPropertiesFilterDialect = null;
            string[]     messageContentSchemaLocation    = null;
            XmlElement[] any = null;

            if (Security == Security.None)
            {
                Action action = ConstructSecurityTolerantAction(
                    () =>
                {
                    // query properties
                    response = Client.GetEventProperties(out fixedTopicSet,
                                                         out topicSet,
                                                         out topicExpressionDialect,
                                                         out messageContentFilterDialect,
                                                         out producerPropertiesFilterDialect,
                                                         out messageContentSchemaLocation,
                                                         out any);
                }
                    );

                action();
            }
            else
            {
                response = Client.GetEventProperties(out fixedTopicSet,
                                                     out topicSet,
                                                     out topicExpressionDialect,
                                                     out messageContentFilterDialect,
                                                     out producerPropertiesFilterDialect,
                                                     out messageContentSchemaLocation,
                                                     out any);
            }

            return(topicSet);
        }
Esempio n. 13
0
        public static string[] GetEventProperties(this IEventService s, out bool FixedTopicSet, out TopicSetType TopicSet, out string[] TopicExpressionDialect, out string[] MessageContentFilterDialect, out string[] ProducerPropertiesFilterDialect, out string[] MessageContentSchemaLocation, out System.Xml.XmlElement[] Any)
        {
            s.InitializeGuard();

            string[] response = null;

            bool         fixedTopicSetCopy = false;
            TopicSetType topicSetCopy      = null;

            string[]     topicExpressionDialectCopy          = null;
            string[]     messageContentFilterDialectCopy     = null;
            string[]     producerPropertiesFilterDialectCopy = null;
            string[]     messageContentSchemaLocationCopy    = null;
            XmlElement[] anyCopy = null;

            s.Test.RunStep(() =>
            {
                response = s.ServiceClient.Port.GetEventProperties(out fixedTopicSetCopy,
                                                                   out topicSetCopy,
                                                                   out topicExpressionDialectCopy,
                                                                   out messageContentFilterDialectCopy,
                                                                   out producerPropertiesFilterDialectCopy,
                                                                   out messageContentSchemaLocationCopy,
                                                                   out anyCopy);
            },
                           "Get Event Properties");

            FixedTopicSet                   = fixedTopicSetCopy;
            TopicSet                        = topicSetCopy;
            TopicExpressionDialect          = topicExpressionDialectCopy;
            MessageContentFilterDialect     = messageContentFilterDialectCopy;
            ProducerPropertiesFilterDialect = producerPropertiesFilterDialectCopy;
            MessageContentSchemaLocation    = messageContentSchemaLocationCopy;
            Any = anyCopy;

            return(response);
        }
Esempio n. 14
0
        /// <summary>
        /// Gets TopicSet
        /// </summary>
        /// <returns></returns>
        protected TopicSetType GetTopicSet()
        {
            string[] response = null;

            bool         fixedTopicSet = false;
            TopicSetType topicSet      = null;

            string[]     topicExpressionDialect          = null;
            string[]     messageContentFilterDialect     = null;
            string[]     producerPropertiesFilterDialect = null;
            string[]     messageContentSchemaLocation    = null;
            XmlElement[] any = null;

            // query properties
            response = GetEventProperties(out fixedTopicSet,
                                          out topicSet,
                                          out topicExpressionDialect,
                                          out messageContentFilterDialect,
                                          out producerPropertiesFilterDialect,
                                          out messageContentSchemaLocation,
                                          out any);

            return(topicSet);
        }
Esempio n. 15
0
        public static TopicSetType GetTopicSet(this IEventService s)
        {
            s.InitializeGuard();

            bool         fixedTopicSet = false;
            TopicSetType topicSet      = null;

            string[]     topicExpressionDialect          = null;
            string[]     messageContentFilterDialect     = null;
            string[]     producerPropertiesFilterDialect = null;
            string[]     messageContentSchemaLocation    = null;
            XmlElement[] any = null;

            // query properties
            s.GetEventProperties(out fixedTopicSet,
                                 out topicSet,
                                 out topicExpressionDialect,
                                 out messageContentFilterDialect,
                                 out producerPropertiesFilterDialect,
                                 out messageContentSchemaLocation,
                                 out any);

            return(topicSet);
        }
Esempio n. 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            Unsubscribe();
            listBox1.Items.Clear();
            string ip   = txtIP.Text;
            int    port = Convert.ToInt16(numPort.Value);

            EventPortTypeClient eptc = OnvifServices.GetEventClient(ip, port);

            // 1. Get Event Properties
            bool         fixedTopicSet;
            TopicSetType tst = new TopicSetType();

            string[]     topicExpDialect;
            string[]     msgContentFilter;
            string[]     producerProperties;
            string[]     msgContentSchema;
            XmlElement[] any;

            string[] result = eptc.GetEventProperties(out fixedTopicSet, out tst, out topicExpDialect, out msgContentFilter, out producerProperties, out msgContentSchema, out any);

            listBox1.Items.Add(string.Format("Result: {0}", result));
            listBox1.Items.Add(string.Format("Message Content Filter Dialect(s)"));
            foreach (string msg in msgContentFilter)
            {
                listBox1.Items.Add(string.Format("  {0}", msg));
            }

            listBox1.Items.Add("");
            listBox1.Items.Add(string.Format("Message Content Schema Location(s)"));
            foreach (string msg in msgContentSchema)
            {
                listBox1.Items.Add(string.Format("  {0}", msg));
            }

            listBox1.Items.Add("");
            listBox1.Items.Add(string.Format("Producer Properties Filter Dialect(s)"));
            foreach (string msg in producerProperties)
            {
                listBox1.Items.Add(string.Format("  {0}", msg));
            }

            listBox1.Items.Add("");
            listBox1.Items.Add(string.Format("Topic Expression Dialect(s)"));
            foreach (string msg in topicExpDialect)
            {
                listBox1.Items.Add(string.Format("  {0}", msg));
            }

            listBox1.Items.Add("");
            listBox1.Items.Add(string.Format("Topic Set item(s)"));
            foreach (XmlElement x in tst.Any)
            {
                listBox1.Items.Add("  " + x.Name);
            }

            // 2. Get capabilities
            Capabilities c = eptc.GetServiceCapabilities();

            listBox1.Items.Add("");
            listBox1.Items.Add("Capabilites");
            listBox1.Items.Add(string.Format("  MaxNotificationProducers: {0}", c.MaxNotificationProducers));
            listBox1.Items.Add(string.Format("  MaxNotificationProducersSpecified: {0}", c.MaxNotificationProducersSpecified));
            listBox1.Items.Add(string.Format("  MaxPullPoints: {0}", c.MaxPullPoints));
            listBox1.Items.Add(string.Format("  MaxPullPointsSpecified: {0}", c.MaxPullPointsSpecified));
            listBox1.Items.Add(string.Format("  PersistentNotificationStorage: {0}", c.PersistentNotificationStorage));
            listBox1.Items.Add(string.Format("  PersistentNotificationStorageSpecified: {0}", c.PersistentNotificationStorageSpecified));
            listBox1.Items.Add(string.Format("  WSPausableSubscriptionManagerInterfaceSupport: {0}", c.WSPausableSubscriptionManagerInterfaceSupport));
            listBox1.Items.Add(string.Format("  WSPausableSubscriptionManagerInterfaceSupportSpecified: {0}", c.WSPausableSubscriptionManagerInterfaceSupportSpecified));
            listBox1.Items.Add(string.Format("  WSPullPointSupport: {0}", c.WSPullPointSupport));
            listBox1.Items.Add(string.Format("  WSPullPointSupportSpecified: {0}", c.WSPullPointSupportSpecified));
            listBox1.Items.Add(string.Format("  WSSubscriptionPolicySupport: {0}", c.WSSubscriptionPolicySupport));
            listBox1.Items.Add(string.Format("  WSSubscriptionPolicySupportSpecified: {0}", c.WSSubscriptionPolicySupportSpecified));

            //3. Subscribe to notifications
            Subscribe(ip, port);

            //pull(ip, port);
            //test(ip, port);
        }
Esempio n. 17
0
        public void GetEventPropertiesTest()
        {
            RunTest(() =>
            {
                string[] response = null;

                bool faultReceived = false;

                bool fixedTopicSet                       = false;
                TopicSetType topicSet                    = null;
                string[] topicExpressionDialect          = null;
                string[] messageContentFilterDialect     = null;
                string[] producerPropertiesFilterDialect = null;
                string[] messageContentSchemaLocation    = null;
                System.Xml.XmlElement[] any              = null;

                EnsureEventPortTypeClientCreated();

                RunStep(
                    () =>
                {
                    response = _eventPortTypeClient.GetEventProperties(out fixedTopicSet,
                                                                       out topicSet,
                                                                       out topicExpressionDialect,
                                                                       out messageContentFilterDialect,
                                                                       out producerPropertiesFilterDialect,
                                                                       out messageContentSchemaLocation,
                                                                       out any);
                },
                    "Get Event Properties",
                    new ValidateTypeFault(
                        (System.ServiceModel.FaultException fault, out string reason) =>
                {
                    reason        = string.Empty;
                    faultReceived = (fault != null);
                    return(true);
                }));

                // NVT returns any SOAP fault - PASS
                if (faultReceived)
                {
                    return;
                }

                bool allExceptTopicSetNull = (response == null || response.Length == 0) &&
                                             (topicExpressionDialect == null ||
                                              topicExpressionDialect.Length == 0) &&
                                             (producerPropertiesFilterDialect == null ||
                                              producerPropertiesFilterDialect.Length == 0) &&
                                             (messageContentSchemaLocation == null ||
                                              messageContentSchemaLocation.Length == 0) &&
                                             (any == null || any.Length == 0) && !fixedTopicSet;


                //The response is completely empty
                if ((topicSet == null) && allExceptTopicSetNull)
                {
                    Assert(true, "", "Validate response", "The response is empty");
                    return;
                }

                // The response only contains TopicSet element where any child element is not present
                if (allExceptTopicSetNull && topicSet != null)
                {
                    if ((topicSet.Any == null || topicSet.Any.Length == 0) &&
                        topicSet.documentation == null)
                    {
                        Assert(true, "", "Validate response", "The response only contains TopicSet element where any child element is not present");
                        return;
                    }
                }


                // 5. Validate that the mandatory TopicExpressionDialects are supported by the NVT
                bool bConcreteExpressionDialectFound    = false;
                bool bConcreteSetExpressionDialectFound = false;


                Assert(topicExpressionDialect != null, "No Topic Expression Dialects returned", "Check that the DUT returned Topic Expression Dialects");

                bConcreteExpressionDialectFound = topicExpressionDialect.Contains(OnvifMessage.CONCRETETOPIC,
                                                                                  StringComparer.InvariantCultureIgnoreCase);

                Assert(bConcreteExpressionDialectFound,
                       string.Format("Mandatory Topic Expression Dialect {0} not found", OnvifMessage.CONCRETETOPIC),
                       string.Format("Check that Mandatory Topic Expression Dialect {0} is supported", OnvifMessage.CONCRETETOPIC));

                bConcreteSetExpressionDialectFound = topicExpressionDialect.Contains(OnvifMessage.CONCRETESETTOPIC,
                                                                                     StringComparer.InvariantCultureIgnoreCase);

                Assert(bConcreteSetExpressionDialectFound,
                       string.Format("Mandatory Topic Expression Dialect {0} not found", OnvifMessage.CONCRETESETTOPIC),
                       string.Format("Check that Mandatory Topic Expression Dialect {0} is supported", OnvifMessage.CONCRETESETTOPIC));

                // 6. Validate that the mandatory MessageContentFilterDialects is supported by the NVT

                Assert(messageContentFilterDialect != null,
                       "No Message Content Filter Dialects returned",
                       "Check that the DUT returned Message Content Filter Dialects");

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

                bool bMandatoryDialectFound = messageContentFilterDialect.Contains(mandatoryDialect,
                                                                                   StringComparer.InvariantCultureIgnoreCase);

                Assert(bMandatoryDialectFound,
                       string.Format("Mandatory Message Content Filter Dialect {0} not found", mandatoryDialect),
                       string.Format("Check if the DUT supports mandatory Message Content Filter Dialect {0}", mandatoryDialect));

                // 7. Verify that the NVT returns a valid topic namepace

                //
                // I think you should validate that there is at least one topic namespace
                // and that it is a valid string for an uri. All other testing could cause problems,
                // because you need not support the onvif topic namespace (unfortunally)
                // and you could only use your own vendor specific namespace.
                //
                //

                bool bFound = false;

                foreach (string result in response)
                {
                    if (result.IsValidUrl())
                    {
                        bFound = true;
                        break;
                    }
                }

                Assert(bFound, "No valid topic namespace found", "Check if response contains at least one topic namespace and that it is a valid string for an uri");

                // 8. Verify that the DUT supports at least one Topic Set, validate that the TopicSet is well formed
                // !!! response assumes exactly one or none TopicSets !!!
                ValidateTopicSet(topicSet);
            });
        }
Esempio n. 18
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" });
        }
Esempio n. 19
0
        internal StepType GetEventPropertiesTest(out string[] target, out bool FixedTopicSet, out TopicSetType TopicSet, out string[] TopicExpressionDialect, out string[] MessageContentFilterDialect, out string[] ProducerPropertiesFilterDialect, out string[] MessageContentSchemaLocation, out XmlElement[] Any, out SoapException ex, out int timeOut)
        {
            StepType res = StepType.None;

            target  = new string[1];
            timeOut = 0;
            ex      = null;
            bool   passed     = true;
            string logMessage = "";

            FixedTopicSet                   = true;
            TopicSet                        = new TopicSetType();
            TopicExpressionDialect          = new string[1];
            MessageContentFilterDialect     = new string[1];
            ProducerPropertiesFilterDialect = new string[1];
            MessageContentSchemaLocation    = new string[1];
            Any = new XmlElement[1];

            //Get step list for command
            XmlNodeList m_testList = m_TestCommon.GetStepsForCommand("GetEventProperties");

            if (m_testList != null)
            {
                //Get current step
                XmlNode test = m_testList[m_commandCount[GetEventProperties]];

                //Generate response
                object targetObj;

                //TopicNamespaceLocation
                res    = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(string[]), "TopicNamespaceLocation");
                target = (string[])targetObj;

                #region Serialization Temp
                //bool dsr = false;
                //XmlSerializer serializer1 = new XmlSerializer(typeof(bool));
                //TextWriter textWriter = new StreamWriter("c:\\2.txt");
                //serializer1.Serialize(textWriter, dsr);
                #endregion //Serialization Temp

                //FixedTopicSet
                res           = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(bool), "FixedTopicSet");
                FixedTopicSet = (bool)targetObj;

                //TopicSet
                res      = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(TopicSetType), "TopicSet");
                TopicSet = (TopicSetType)targetObj;

                //TopicExpressionDialect
                res = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(string[]), "TopicExpressionDialect");
                TopicExpressionDialect = (string[])targetObj;

                //MessageContentFilterDialect
                res = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(string[]), "MessageContentFilterDialect");
                MessageContentFilterDialect = (string[])targetObj;

                //ProducerPropertiesFilterDialect
                res = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(string[]), "ProducerPropertiesFilterDialect");
                ProducerPropertiesFilterDialect = (string[])targetObj;

                //MessageContentSchemaLocation
                res = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(string[]), "MessageContentSchemaLocation");
                MessageContentSchemaLocation = (string[])targetObj;

                //Any
                res = m_TestCommon.GenerateResponseStepTypeNotVoidSpecificXPath(test, out targetObj, out ex, out timeOut, typeof(XmlElement[]), "Any");
                Any = (XmlElement[])targetObj;



                //Log message
                m_TestCommon.writeToLog(test, logMessage, passed);

                Increment(m_testList.Count, GetEventProperties);
            }
            else
            {
                timeOut = 0;
                target  = null;
                ex      = null;
                res     = StepType.None;
            }
            return(res);
        }
Esempio n. 20
0
        public void SeekBufferBeginTest()
        {
            SubscriptionHandler Handler = new SubscriptionHandler(this, false);
            EventsVerifyPolicy  policy  = new EventsVerifyPolicy(false);

            policy.VerifyDataPresence     = false;
            policy.VerifyMessagesPresence = false;
            Handler.SetPolicy(policy);
            RunTest(
                () =>
            {
                Handler.SetAddress(GetEventServiceAddress());

                TopicSetType topicSet = Handler.GetTopicSet();

                VerifySeekTopics(topicSet);

                SubscribeToBegin(Handler);
                DateTime RefPoint = DateTime.Now;
                Dictionary <NotificationMessageHolderType, XmlElement> NotificationMessages;
                Handler.GetProxy().Seek(RefPoint.ToUniversalTime(), true);
                Handler.GetMessages(1, out NotificationMessages);
                if (NotificationMessages.Count < 1)
                {
                    Assert(false,
                           "No messages",
                           "Check if there are messages");
                }
                VerifyBeginType(NotificationMessages);
                RefPoint = GetMessageTime(GetFirstMessage(NotificationMessages));

                Handler.GetMessages(1, out NotificationMessages);
                if (NotificationMessages.Count >= 1)
                {
                    Assert(false,
                           "There was more than one Begin of Buffer event notification or another unexpected notification recieved. There should be no notifications in current response.",
                           "Check if there are messages");
                }


                Handler.GetProxy().Seek(RefPoint.ToUniversalTime(), false);
                Handler.GetMessages(1, out NotificationMessages);
                if (NotificationMessages.Count < 1)
                {
                    Assert(false,
                           "No messages",
                           "Check if there are messages");
                }
                VerifyBeginType(NotificationMessages);
                RefPoint = GetMessageTime(GetFirstMessage(NotificationMessages));

                Handler.GetMessages(1, out NotificationMessages);
                if (NotificationMessages.Count >= 1)
                {
                    Assert(false,
                           "There was more than one Begin of Buffer event notification or another unexpected notification recieved. There should be no notifications in current response.",
                           "Check if there are messages");
                }
            },
                () =>
            {
                SubscriptionHandler.Unsubscribe(Handler);
            });
        }
 public Model(
     bool isPtzStatusSupported, bool isPtzPositionSupported, string[] messageContentFilterDialects, string[] topicExpressionDialects, bool isFixedTopicSet, TopicSetType topicSet
     )
 {
     this.isPtzStatusSupported         = isPtzStatusSupported;
     this.isPtzPositionSupported       = isPtzPositionSupported;
     this.messageContentFilterDialects = messageContentFilterDialects;
     this.topicExpressionDialects      = topicExpressionDialects;
     this.isFixedTopicSet = isFixedTopicSet;
     this.topicSet        = topicSet;
 }