示例#1
0
        public void Resolve_XsdFile_ImportsDiscovered()
        {
            string xsdFileName = TestFiles.GetFilePath(TestFiles.RestaurantMessagesXsdFileName);
            IEnumerable <MetadataSection> metadataSections = DiscoveryMetadataResolver.Resolve(xsdFileName);

            Assert.That(metadataSections, Has.Count.EqualTo(2));
            Assert.That(metadataSections.Count(m => m.Identifier == TestNamespaces.DataNamespace), Is.EqualTo(1));
            Assert.That(metadataSections.Count(m => m.Identifier == TestNamespaces.MessageNamespace), Is.EqualTo(1));
        }
        private static IEnumerable <MetadataSection> Resolve(EndpointAddress endpointReference, bool useDisco)
        {
            MetadataSet metadata;

            try
            {
                if (useDisco)
                {
                    return(DiscoveryMetadataResolver.Resolve(endpointReference.Uri.AbsoluteUri));
                }
                MetadataExchangeClient client = CreateMetadataExchangeClient(endpointReference);
                client.OperationTimeout = TimeSpan.FromMinutes(metadataExchangeClientTimeoutMinutes);
                metadata = client.GetMetadata(endpointReference);
            }
            catch (Exception exception)
            {
                throw new MetadataDiscoveryException(exception.Message, exception);
            }
            return(metadata.MetadataSections);
        }