Example #1
0
        private MetadataSection CreateMetadataSection(object document)
        {
            System.Web.Services.Description.ServiceDescription description =
                document as System.Web.Services.Description.ServiceDescription;

            XmlSchema       schema  = document as XmlSchema;
            XmlElement      element = document as XmlElement;
            MetadataSection section;

            if (description != null)
            {
                section = MetadataSection.CreateFromServiceDescription(description);
            }
            else if (schema != null)
            {
                section = MetadataSection.CreateFromSchema(schema);
            }
            else if ((element != null) && IsPolicyElement(element))
            {
                section = MetadataSection.CreateFromPolicy(element, null);
            }
            else
            {
                section          = new MetadataSection();
                section.Metadata = document;
            }

            return(section);
        }
Example #2
0
        private void AddDocumentToResults(object document, Collection <MetadataSection> results)
        {
            var wsdl   = document as ServiceDescription;
            var schema = document as XmlSchema;
            var xmlDoc = document as XmlElement;

            if (wsdl != null)
            {
                results.Add(MetadataSection.CreateFromServiceDescription(wsdl));
            }
            else if (schema != null)
            {
                results.Add(MetadataSection.CreateFromSchema(schema));
            }
            else if (xmlDoc != null && xmlDoc.LocalName == "Policy")
            {
                results.Add(MetadataSection.CreateFromPolicy(xmlDoc, null));
            }
            else
            {
                var mexDoc = new MetadataSection {
                    Metadata = document
                };
                results.Add(mexDoc);
            }
        }
Example #3
0
        void AddDocumentToResults(object document, Collection <MetadataSection> results)
        {
            WsdlNS.ServiceDescription wsdl = document as WsdlNS.ServiceDescription;
            XmlSchema  schema = document as XmlSchema;
            XmlElement xmlDoc = document as XmlElement;

            if (wsdl != null)
            {
                results.Add(MetadataSection.CreateFromServiceDescription(wsdl));
            }
            else if (schema != null)
            {
                results.Add(MetadataSection.CreateFromSchema(schema));
            }
            else if (xmlDoc != null && xmlDoc.LocalName == "Policy")
            {
                results.Add(MetadataSection.CreateFromPolicy(xmlDoc, null));
            }
            else
            {
                MetadataSection mexDoc = new MetadataSection();
                mexDoc.Metadata = document;
                results.Add(mexDoc);
            }
        }
Example #4
0
        private static IEnumerable <MetadataSection> LoadAsPolicy(XmlReader reader, string path)
        {
            XmlDocument document;

            try
            {
                document = new XmlDocument();
                document.Load(reader);
            }
            catch (Exception exception)
            {
                if (exception.IsFatal())
                {
                    throw;
                }

                string message = string.Format("WS-Policy Parsing Error while reading: '{0}'. Verify that the XML is both well-formed and valid.", path);
                throw new MetadataDiscoveryException(message);
            }
            XmlElement documentElement = document.DocumentElement;

            return((documentElement != null)
                                ? new List <MetadataSection> {
                MetadataSection.CreateFromPolicy(documentElement, null)
            }
                                : Enumerable.Empty <MetadataSection>());
        }
        private static void AddDocumentToSet(MetadataSet metadataSet, object document)
        {
            ServiceDescription serviceDescription = document as ServiceDescription;
            XmlSchema          schema             = document as XmlSchema;
            XmlElement         policy             = document as XmlElement;

            if (serviceDescription != null)
            {
                metadataSet.MetadataSections.Add(MetadataSection.CreateFromServiceDescription(serviceDescription));
            }
            else if (schema != null)
            {
                metadataSet.MetadataSections.Add(MetadataSection.CreateFromSchema(schema));
            }
            else if ((policy != null) && IsPolicyElement(policy))
            {
                metadataSet.MetadataSections.Add(MetadataSection.CreateFromPolicy(policy, null));
            }
            else
            {
                MetadataSection item = new MetadataSection {
                    Metadata = document
                };
                metadataSet.MetadataSections.Add(item);
            }
        }
Example #6
0
        private static void AddDocumentToResults(object document, ICollection <MetadataSection> results)
        {
            ServiceDescription serviceDescription = document as ServiceDescription;
            XmlSchema          xmlSchema          = document as XmlSchema;
            XmlElement         xmlElement         = document as XmlElement;

            if (serviceDescription != null)
            {
                results.Add(MetadataSection.CreateFromServiceDescription(serviceDescription));
            }
            else if (xmlSchema != null)
            {
                results.Add(MetadataSection.CreateFromSchema(xmlSchema));
            }
            else if (xmlElement != null && (xmlElement.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/policy" || xmlElement.NamespaceURI == "http://www.w3.org/ns/ws-policy") && xmlElement.LocalName == "Policy")
            {
                results.Add(MetadataSection.CreateFromPolicy(xmlElement, null));
            }
            else
            {
                MetadataSection mexDoc = new MetadataSection();
                mexDoc.Metadata = document;
                results.Add(mexDoc);
            }
        }
        void AddDocumentToSet(MetadataSet metadataSet, object document)
        {
            WsdlNS.ServiceDescription wsdl = document as WsdlNS.ServiceDescription;
            XmlSchema  schema = document as XmlSchema;
            XmlElement xmlDoc = document as XmlElement;

            if (wsdl != null)
            {
                metadataSet.MetadataSections.Add(MetadataSection.CreateFromServiceDescription(wsdl));
            }
            else if (schema != null)
            {
                metadataSet.MetadataSections.Add(MetadataSection.CreateFromSchema(schema));
            }
            else if (xmlDoc != null && MetadataSection.IsPolicyElement(xmlDoc))
            {
                metadataSet.MetadataSections.Add(MetadataSection.CreateFromPolicy(xmlDoc, null));
            }
            else
            {
                MetadataSection mexDoc = new MetadataSection();
                mexDoc.Metadata = document;
                metadataSet.MetadataSections.Add(mexDoc);
            }
        }
        private void LoadAsPolicy(XmlNS.XmlReader reader)
        {
            var doc = new XmlNS.XmlDocument();

            doc.XmlResolver = null;
            doc.Load(reader);
            XmlNS.XmlElement policy = doc.DocumentElement;
            _metadataSections.Add(MetadataSection.CreateFromPolicy(policy, null));
        }
Example #9
0
        private void DownloadMetadata()
        {
            var results = new Collection <MetadataSection>();

            if (DiscoveryClient.Documents.Values != null)
            {
                foreach (var document in DiscoveryClient.Documents.Values)
                {
                    var wsdl   = document as System.Web.Services.Description.ServiceDescription;
                    var schema = document as XmlSchema;
                    var xmlDoc = document as XmlElement;

                    if (wsdl != null)
                    {
                        var metaSect = MetadataSection.CreateFromServiceDescription(wsdl);
                        results.Add(metaSect);
                    }
                    else if (schema != null)
                    {
                        results.Add(MetadataSection.CreateFromSchema(schema));
                    }
                    else if (xmlDoc != null && xmlDoc.LocalName == "Policy")
                    {
                        results.Add(MetadataSection.CreateFromPolicy(xmlDoc, null));
                    }
                    else
                    {
                        var mexDoc = new MetadataSection();
                        mexDoc.Metadata = document;
                        results.Add(mexDoc);
                    }
                }
            }

            Metadata = results;
        }
Example #10
0
 private MetadataSection MapFromXmlElement(XmlElement document)
 {
     return(MetadataSection.CreateFromPolicy(document, null));
 }