コード例 #1
0
 private static MetadataFileType DetermineFileType(XmlNS.XmlReader reader)
 {
     try
     {
         if (reader.IsStartElement(MetadataConstants.WSDL.Elements.Root, MetadataConstants.WSDL.NamespaceUri))
         {
             return(MetadataFileType.Wsdl);
         }
         else if (reader.IsStartElement(MetadataConstants.XmlSchema.Elements.Root, MetadataConstants.XmlSchema.NamespaceUri))
         {
             return(MetadataFileType.Xsd);
         }
         else if (reader.IsStartElement(MetadataConstants.WSPolicy.Elements.Policy, MetadataConstants.WSPolicy.NamespaceUri) ||
                  reader.IsStartElement(MetadataConstants.WSPolicy.Elements.Policy, MetadataConstants.WSPolicy.NamespaceUri15))
         {
             return(MetadataFileType.Policy);
         }
         else if (reader.IsStartElement(MetadataConstants.WSAddressing.Elements.EndpointReference, MetadataConstants.WSAddressing.NamespaceUri))
         {
             return(MetadataFileType.Epr);
         }
         else
         {
             return(MetadataFileType.UnknownXml);
         }
     }
     catch (XmlNS.XmlException)
     {
         //This must mean that the document isn't an XML Document so we continue trying other things...
         return(MetadataFileType.NonXml);
     }
 }
コード例 #2
0
        private async Task LoadAsWsdlAsync(XmlNS.XmlReader reader, string uri, string basePath, CancellationToken cancellationToken)
        {
            WsdlNS.ServiceDescription wsdl = await AsyncHelper.RunAsync(() => WsdlNS.ServiceDescription.Read(reader), cancellationToken).ConfigureAwait(false);

            wsdl.RetrievalUrl = uri;

            if (_resolveExternalDocs)
            {
                foreach (WsdlNS.Import import in wsdl.Imports)
                {
                    if (!string.IsNullOrWhiteSpace(import.Location))
                    {
                        var resolvedLocation = await LoadAsSchemaImportLocationAsync(import.Location, uri, basePath, import.Namespace, ".wsdl", cancellationToken).ConfigureAwait(false);

                        import.Location = resolvedLocation;
                    }
                }

                foreach (XmlNS.Schema.XmlSchema schema in wsdl.Types.Schemas)
                {
                    schema.SourceUri = uri;
                    await LoadAsXmlSchemaIncludesAsync(schema, wsdl.RetrievalUrl, basePath, cancellationToken).ConfigureAwait(false);
                }
            }

            _metadataSections.Add(MetadataSection.CreateFromServiceDescription(wsdl));
        }
コード例 #3
0
        private void LoadAsUnknownXml(XmlNS.XmlReader reader)
        {
            var doc = new XmlNS.XmlDocument();

            doc.XmlResolver = null;
            doc.Load(reader);
            XmlNS.XmlElement unknownXml = doc.DocumentElement;
            _metadataSections.Add(new MetadataSection(null, null, unknownXml));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        private async Task LoadAsEPRAsync(XmlNS.XmlReader reader, CancellationToken cancellationToken)
        {
            using (var dictionaryReader = XmlNS.XmlDictionaryReader.CreateDictionaryReader(reader))
            {
                EndpointAddress epr = await AsyncHelper.RunAsync(() => EndpointAddress.ReadFrom(dictionaryReader), cancellationToken).ConfigureAwait(false);

                MetadataExchangeResolver      resolver         = MetadataExchangeResolver.Create(epr, null, null, null);
                IEnumerable <MetadataSection> resolvedMetadata = await resolver.ResolveMetadataAsync(cancellationToken).ConfigureAwait(false);

                _metadataSections.AddRange(resolvedMetadata);
            }
        }
コード例 #6
0
        private async Task LoadAsXmlSchemaAsync(XmlNS.XmlReader reader, string uri, string basePath, CancellationToken cancellationToken)
        {
            var schema = await AsyncHelper.RunAsync(() => XmlNS.Schema.XmlSchema.Read(reader, null), cancellationToken).ConfigureAwait(false);

            _metadataSections.Add(MetadataSection.CreateFromSchema(schema));
            schema.SourceUri = uri;

            if (_resolveExternalDocs)
            {
                await LoadAsXmlSchemaIncludesAsync(schema, uri, basePath, cancellationToken).ConfigureAwait(false);
            }
        }
コード例 #7
0
 public override System.Boolean CanDeserialize(Microsoft.Xml.XmlReader xmlReader)
 {
     return(true);
 }