private DpwsServiceDescriptions ProcessMatch(DpwsServiceDescription.ServiceDescriptionType type, WsMessage response, string messageID, IPEndPoint remoteEP, WsMessageCheck messageCheck)
        {
            Microsoft.SPOT.Debug.Assert(type == DpwsServiceDescription.ServiceDescriptionType.ProbeMatch ||
                                        type == DpwsServiceDescription.ServiceDescriptionType.ResolveMatch);

            // Parse and build header
            WsWsaHeader header = response.Header;
            XmlReader   reader = response.Reader;

            if (header == null || reader == null)
            {
                return(null);
            }

            try
            {
                // Make sure this is a probe matches response
                String headerAction = (type == DpwsServiceDescription.ServiceDescriptionType.ProbeMatch) ?
                                      m_version.DiscoveryNamespace + "/ProbeMatches" :
                                      m_version.DiscoveryNamespace + "/ResolveMatches";

                if (header.Action != headerAction)
                {
                    return(null);
                }

                // Make sure this is not a duplicate probe response
                if (messageCheck != null)
                {
                    if (messageCheck.IsDuplicate(header.MessageID, remoteEP.ToString()) == true)
                    {
                        System.Ext.Console.Write("ProbeMatches / ResolveMatches - Duplicate response - " + header.Action + " received");
                        return(null);
                    }
                }

                // Make sure the messageID matches the request ID
                if (header.RelatesTo != messageID)
                {
                    return(null);
                }

                // Process the probe matches
#if DEBUG
                int depth = reader.Depth;
#endif
                DpwsServiceDescriptions matches = new DpwsServiceDescriptions(reader, type, m_version, remoteEP);
#if DEBUG
                Microsoft.SPOT.Debug.Assert(XmlReaderHelper.HasReadCompleteNode(depth, reader));
#endif

                return(matches);
            }
            finally
            {
                reader.Close();
            }
        }
Пример #2
0
        internal DpwsServiceDescriptions(XmlReader reader, DpwsServiceDescription.ServiceDescriptionType type, ProtocolVersion v, IPEndPoint remoteEP)
        {
            m_threadLock          = new object();
            m_serviceDescriptions = new ArrayList();

            Microsoft.SPOT.Debug.Assert(type == DpwsServiceDescription.ServiceDescriptionType.ProbeMatch ||
                                        type == DpwsServiceDescription.ServiceDescriptionType.ResolveMatch);

            String collectionName, itemName;

            if (type == DpwsServiceDescription.ServiceDescriptionType.ProbeMatch)
            {
                collectionName = "ProbeMatches";
                itemName       = "ProbeMatch";
            }
            else
            {
                collectionName = "ResolveMatches";
                itemName       = "ResolveMatch";
            }

            reader.ReadStartElement(collectionName, v.DiscoveryNamespace);

            while (reader.IsStartElement(itemName, v.DiscoveryNamespace))
            {
#if DEBUG
                int depth = reader.Depth;
#endif
                m_serviceDescriptions.Add(new DpwsServiceDescription(reader, type, v, remoteEP));
#if DEBUG
                Microsoft.SPOT.Debug.Assert(XmlReaderHelper.HasReadCompleteNode(depth, reader));
#endif
            }

            if (type == DpwsServiceDescription.ServiceDescriptionType.ResolveMatch && m_serviceDescriptions.Count > 1)
            {
                // Per schema, there can only be 1 resolve match
                throw new XmlException();
            }

            XmlReaderHelper.SkipAllSiblings(reader); // xs:any
            reader.ReadEndElement();                 // collectionName
        }
Пример #3
0
        internal DpwsServiceDescriptions(XmlReader reader, DpwsServiceDescription.ServiceDescriptionType type)
        {
            Microsoft.SPOT.Debug.Assert(type == DpwsServiceDescription.ServiceDescriptionType.ProbeMatch ||
                                        type == DpwsServiceDescription.ServiceDescriptionType.ResolveMatch);

            String collectionName, itemName;

            if (type == DpwsServiceDescription.ServiceDescriptionType.ProbeMatch)
            {
                collectionName = "ProbeMatches";
                itemName       = "ProbeMatch";
            }
            else
            {
                collectionName = "ResolveMatches";
                itemName       = "ResolveMatch";
            }

            reader.ReadStartElement(collectionName, WsWellKnownUri.WsdNamespaceUri);

            while (reader.IsStartElement(itemName, WsWellKnownUri.WsdNamespaceUri))
            {
#if DEBUG
                int depth = reader.Depth;
#endif
                m_serviceDescriptions.Add(new DpwsServiceDescription(reader, type));
#if DEBUG
                Microsoft.SPOT.Debug.Assert(XmlReaderHelper.HasReadCompleteNode(depth, reader));
#endif
            }

            if (type == DpwsServiceDescription.ServiceDescriptionType.ResolveMatch && m_serviceDescriptions.Count > 1)
            {
                // Per schema, there can only be 1 resolve match
                throw new XmlException();
            }

            XmlReaderHelper.SkipAllSiblings(reader); // xs:any
            reader.ReadEndElement();                 // collectionName
        }