コード例 #1
0
        List <TopicInfo> GetTopicInfos(string response)
        {
            XmlDocument soapRawResponse = BaseNotificationXmlUtils.GetRawResponse(response);

            // find Topic elements in "raw" packet
            string topicPath;

            topicPath = "/s:Envelope/s:Body/events:GetEventPropertiesResponse/t1:TopicSet";
            XmlNamespaceManager manager = CreateNamespaceManager(soapRawResponse);

            manager.AddNamespace("t1", "http://docs.oasis-open.org/wsn/t-1");

            XmlNode           topicSetNode    = soapRawResponse.SelectSingleNode(topicPath, manager);
            XmlElement        topicSetElement = topicSetNode as XmlElement;
            List <XmlElement> rootTopics      = new List <XmlElement>();

            foreach (XmlNode node in topicSetElement.ChildNodes)
            {
                XmlElement e = node as XmlElement;
                if (e != null)
                {
                    rootTopics.Add(e);
                }
            }

            // Check that the topic of interest is supported

            // select all topics
            List <XmlElement> topics = new List <XmlElement>();

            foreach (XmlElement element in rootTopics)
            {
                FindTopics(element, topics);
            }

            List <TopicInfo> topicInfos = new List <TopicInfo>();

            foreach (XmlElement topicElement in topics)
            {
                TopicInfo info = TopicInfo.ConstructTopicInfo(topicElement);
                topicInfos.Add(info);
            }

            return(topicInfos);
        }
コード例 #2
0
        public static string GetSoapPacket(string response)
        {
            string rawSoapPacket = null;

            System.IO.StringReader rdr = new StringReader(response);

            string nextLine;

            do
            {
                nextLine = rdr.ReadLine();
            } while (!string.IsNullOrEmpty(nextLine));

            rawSoapPacket = rdr.ReadToEnd();
            // fix for #976
            rawSoapPacket = BaseNotificationXmlUtils.RemoveInvalidXmlChars(rawSoapPacket);



            return(rawSoapPacket);
        }
コード例 #3
0
 public static XmlDocument GetRawResponse(string response)
 {
     return(BaseNotificationXmlUtils.GetRawResponse(response));
 }
コード例 #4
0
ファイル: SearchTest.cs プロジェクト: kudrinyaroslav/ON-0110
        protected List <FindEventResult> GetAllEventsSearchResults(string searchToken,
                                                                   int?minResults,
                                                                   int?maxResults,
                                                                   string waitTime,
                                                                   Dictionary <FindEventResult, XmlElement> rawResults,
                                                                   out SearchState state)
        {
            List <FindEventResult> eventsList = new List <FindEventResult>();

            FindEventResultList   response = null;
            GetEventSearchResults request  = new GetEventSearchResults();

            request.SearchToken         = searchToken;
            request.WaitTime            = waitTime;
            request.MaxResultsSpecified = maxResults.HasValue;
            request.MaxResults          = maxResults.GetValueOrDefault();
            request.MinResultsSpecified = minResults.HasValue;
            request.MinResults          = minResults.GetValueOrDefault();

            string          dump      = string.Empty;
            Action <string> logAction = new Action <string>(str => { dump = str; });

            _trafficListener.ResponseReceived += logAction;

            DateTime started      = DateTime.Now;
            DateTime dueTo        = started.AddSeconds(_searchTimeout);
            bool     completed    = true;
            DateTime lastResponse = DateTime.Now;

            LogTestEvent(string.Format("All results should be received by {0}{1}", dueTo.StdTimeToString(), Environment.NewLine));

            do
            {
                RunStep(() => { response = Client.GetEventSearchResults(request).ResultList; }, "Get Events Search results");
                lastResponse = DateTime.Now;

                var events = response.Result ?? new FindEventResult[0];

                // no request delay here!
                var onvifEvents = events.Where(OnvifMessage.IsOnvifMessage);

                if (events.Count() != onvifEvents.Count())
                {
                    LogStepEvent("WARNING: there is a message from non-ONVIF namespace");
                }

                //if (null != rawResults)
                {
                    var    rdr = new System.IO.StringReader(dump);
                    string nextLine;
                    do
                    {
                        nextLine = rdr.ReadLine();
                    } while (!string.IsNullOrEmpty(nextLine));
                    string rawSoapPacket = rdr.ReadToEnd();
                    // fix for #976
                    rawSoapPacket = BaseNotificationXmlUtils.RemoveInvalidXmlChars(rawSoapPacket);
                    var doc = new XmlDocument();
                    doc.LoadXml(rawSoapPacket);

                    var messagePath = "/s:Envelope/s:Body/search:GetEventSearchResultsResponse/search:ResultList/onvif:Result/onvif:Event";
                    var manager     = new XmlNamespaceManager(doc.NameTable);
                    manager.AddNamespace("s", "http://www.w3.org/2003/05/soap-envelope");
                    manager.AddNamespace("search", "http://www.onvif.org/ver10/search/wsdl");
                    manager.AddNamespace("onvif", "http://www.onvif.org/ver10/schema");
                    manager.AddNamespace("b2", "http://docs.oasis-open.org/wsn/b-2");

                    XmlNodeList responseNodeList = doc.SelectNodes(messagePath, manager);

                    for (int i = 0; i < events.Count(); i++)
                    {
                        var e = events[i];
                        if (OnvifMessage.IsOnvifMessage(e))
                        {
                            eventsList.Add(e);
                            if (null != rawResults)
                            {
                                rawResults.Add(e, responseNodeList[i] as XmlElement);
                            }
                        }
                    }
                }

                if (lastResponse > dueTo)
                {
                    completed = false;
                    break;
                }
            } while (response.SearchState != SearchState.Completed);

            state = response.SearchState;
            _trafficListener.ResponseReceived -= logAction;

            Assert(completed, string.Format("Completed state has not been achieved (last response received at {0}, State: {1})", lastResponse.StdTimeToString(), response.SearchState), "Check that search has been completed in due time");

            return(eventsList);
        }