コード例 #1
0
		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;
		}
コード例 #2
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" });
        }