当前位置: 首页>>代码示例>>C#>>正文


C# MetadataExchangeClient.GetMetadata方法代码示例

本文整理汇总了C#中System.ServiceModel.Description.MetadataExchangeClient.GetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataExchangeClient.GetMetadata方法的具体用法?C# MetadataExchangeClient.GetMetadata怎么用?C# MetadataExchangeClient.GetMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Description.MetadataExchangeClient的用法示例。


在下文中一共展示了MetadataExchangeClient.GetMetadata方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DiscoverMexMetadata

 void DiscoverMexMetadata(object sender, DoWorkEventArgs e)
 {
     Uri url = (Uri)e.Argument;
     var client = new MetadataExchangeClient(url, MetadataExchangeClientMode.MetadataExchange);
     MetadataSet metadata = client.GetMetadata();
     e.Result = new ServiceReferenceDiscoveryEventArgs(metadata);
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:7,代码来源:ServiceReferenceDiscoveryClient.cs

示例2: UseWcf

 static void UseWcf()
 {
     /*
      动态下载服务元数据
      */
     MetadataExchangeClient metaExchangeClient =
         new MetadataExchangeClient(
             new Uri("http://localhost:8002/ManualService"),
             MetadataExchangeClientMode.HttpGet
         );
     //下载元数据
     MetadataSet metadataSet = metaExchangeClient.GetMetadata();
     WsdlImporter importer = new WsdlImporter(metadataSet);
     ServiceEndpointCollection endpointCollection = importer.ImportAllEndpoints();
     IManulService manulProxy = null;
     foreach (ServiceEndpoint endPointItem in endpointCollection)
     {
         manulProxy = new ChannelFactory<IManulService>(
             endPointItem.Binding,
             endPointItem.Address
             ).CreateChannel();
         ((IChannel)manulProxy).Open();
         Console.WriteLine("WCF调用结果为:{0}",
             manulProxy.GetData());
         ((IChannel)manulProxy).Close();
     }
 }
开发者ID:cvs1989,项目名称:hooyeswidget,代码行数:27,代码来源:Program.cs

示例3: GenerateVBCodeForService

        static void GenerateVBCodeForService(Uri metadataAddress, string outputFile)
        {
            MetadataExchangeClient mexClient = new MetadataExchangeClient(metadataAddress, MetadataExchangeClientMode.HttpGet);
              mexClient.ResolveMetadataReferences = true;
              MetadataSet metaDocs = mexClient.GetMetadata();

              WsdlImporter importer = new WsdlImporter(metaDocs);
              ServiceContractGenerator generator = new ServiceContractGenerator();

              System.Collections.ObjectModel.Collection<ContractDescription> contracts = importer.ImportAllContracts();
              foreach (ContractDescription contract in contracts)
              {
            generator.GenerateServiceContractType(contract);
              }
              if (generator.Errors.Count != 0)
            throw new ApplicationException("There were errors during code compilation.");

              // Write the code dom.
              System.CodeDom.Compiler.CodeGeneratorOptions options = new System.CodeDom.Compiler.CodeGeneratorOptions();
              options.BracingStyle = "C";
              System.CodeDom.Compiler.CodeDomProvider codeDomProvider = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("VB");
              System.CodeDom.Compiler.IndentedTextWriter textWriter = new System.CodeDom.Compiler.IndentedTextWriter(new System.IO.StreamWriter(outputFile));
              codeDomProvider.GenerateCodeFromCompileUnit(generator.TargetCompileUnit, textWriter, options);
              textWriter.Close();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:25,代码来源:client.cs

示例4: QueryMexEndpoint

		static ServiceEndpointCollection QueryMexEndpoint(string mexAddress, BindingElement bindingElement)
		{
			var binding = new CustomBinding(bindingElement);
			var MEXClient = new MetadataExchangeClient(binding);
			var metadata = MEXClient.GetMetadata(new EndpointAddress(mexAddress));
			var importer = new WsdlImporter(metadata);
			return importer.ImportAllEndpoints();
		}
开发者ID:Helen1987,项目名称:edu,代码行数:8,代码来源:MetadataHelper.cs

示例5: QueryMexEndpoint

      static ServiceEndpointCollection QueryMexEndpoint(string mexAddress,Binding binding,TokenProvider tokenProvider)
      {
         dynamic extendedBinding = binding;
         extendedBinding.MaxReceivedMessageSize *= MessageSizeMultiplier;

         MetadataExchangeClient mexClient = new MetadataExchangeClient(extendedBinding);
         mexClient.SetServiceBusCredentials(tokenProvider);
         MetadataSet metadata = mexClient.GetMetadata(new EndpointAddress(mexAddress));
         MetadataImporter importer = new WsdlImporter(metadata);
         return importer.ImportAllEndpoints();
      }
开发者ID:ittray,项目名称:LocalDemo,代码行数:11,代码来源:ServiceBusMetadataHelper.cs

示例6: Main

 static void Main(string[] args)
 {
     Console.WriteLine("URI of the metadata documetns retreived");
     //MetadataExchangeClient metaTransfer = new MetadataExchangeClient(new Uri("http://localhost:1169/Service1.svc/mex"), MetadataExchangeClientMode.MetadataExchange);
     MetadataExchangeClient metaTransfer = new MetadataExchangeClient(new Uri("http://localhost:1169/Service1.svc"), MetadataExchangeClientMode.HttpGet);
     metaTransfer.ResolveMetadataReferences = true;
     MetadataSet metadata = metaTransfer.GetMetadata();
     foreach (MetadataSection doc in metadata.MetadataSections)
         Console.WriteLine(doc.Dialect + " : " + doc.Metadata);
     Console.ReadLine();
 }
开发者ID:Edward-Zhou,项目名称:GettingStartedWCF,代码行数:11,代码来源:Program.cs

示例7: Main

 static void Main(string[] args)
 {
     MetadataExchangeClient metadataExchangeClient = new MetadataExchangeClient(new Uri("http://127.0.0.1:3721/calculatorservice/metadata"), MetadataExchangeClientMode.HttpGet);
     metadataExchangeClient.ResolveMetadataReferences = false;
     MetadataSet metadata = metadataExchangeClient.GetMetadata();
     using (XmlWriter writer = new XmlTextWriter("metadata.xml", Encoding.UTF8))
     {
         metadata.WriteTo(writer);
     }
     Process.Start("metadata.xml");
 }
开发者ID:gauge2009,项目名称:RPC,代码行数:11,代码来源:Program.cs

示例8: QueryMexEndpoint

      static ServiceEndpointCollection QueryMexEndpoint(string mexAddress,BindingElement bindingElement)
      {
         dynamic element = bindingElement;
         element.MaxReceivedMessageSize *= MessageSizeMultiplier;

         CustomBinding binding = new CustomBinding(element);
         
         MetadataExchangeClient mexClient = new MetadataExchangeClient(binding);
         MetadataSet metadata = mexClient.GetMetadata(new EndpointAddress(mexAddress));
         MetadataImporter importer = new WsdlImporter(metadata);
         return importer.ImportAllEndpoints();
      }
开发者ID:ittray,项目名称:LocalDemo,代码行数:12,代码来源:MetadataHelper.cs

示例9: GetMetaDataDocs

        private MetadataSet GetMetaDataDocs(EndpointAddress metadataAddress)
        {
            var binding = new WSHttpBinding(SecurityMode.Transport);
            binding.MaxReceivedMessageSize = Int32.MaxValue;
            binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;
            var mexClient = new MetadataExchangeClient(binding)
            {
                ResolveMetadataReferences = true,
                MaximumResolvedReferences = 1000
            };

            var metaDocs = mexClient.GetMetadata(metadataAddress.Uri, MetadataExchangeClientMode.HttpGet);
            return metaDocs;
        }
开发者ID:mredbishop,项目名称:WSDLToTypescriptProxyGenerator,代码行数:14,代码来源:ServiceServiceMetadataImporter.cs

示例10: CreateImporter

        private WsdlImporter CreateImporter(EndPointSetting wsdl)
        {
            var endpoint = new EndpointAddress(wsdl.Uri);

            var binding = new WSHttpBinding(SecurityMode.None)
            {
                MaxReceivedMessageSize = Int32.MaxValue,
            };

            var mex = new MetadataExchangeClient(binding);
            mex.ResolveMetadataReferences = true;

            var metaDocs = mex.GetMetadata(new Uri(wsdl.Uri), MetadataExchangeClientMode.HttpGet);
            return new WsdlImporter(metaDocs);
        }
开发者ID:HEskandari,项目名称:ProxyGen,代码行数:15,代码来源:WcfCodeUnitGenerator.cs

示例11: WebService

        public WebService(string path)
        {
            var metadataAddress = new EndpointAddress(path);
            var mexClient = new MetadataExchangeClient(metadataAddress.Uri, MetadataExchangeClientMode.HttpGet);
            mexClient.ResolveMetadataReferences = true;

            var metadata = mexClient.GetMetadata(metadataAddress.Uri, MetadataExchangeClientMode.HttpGet);
            var metadataSet = new MetadataSet(metadata.MetadataSections);

            var importer = new WsdlImporter(metadataSet);

            AllWsdlDocuments = importer.WsdlDocuments;
            AllContracts = importer.ImportAllContracts();
            AllBindings = importer.ImportAllBindings();
            AllEndpoints = importer.ImportAllEndpoints();

            //AllContracts.First().Operations.First().
        }
开发者ID:kmcgain,项目名称:WsdlGenerator,代码行数:18,代码来源:WebService.cs

示例12: Main

 static void Main(string[] args)
 {
     Binding binding = MetadataExchangeBindings.CreateMexHttpBinding();
     EndpointAddress address = new EndpointAddress("http://127.0.0.1:9999/calculatorservice/mex");
     MetadataExchangeClient metadataExchangeClient = new MetadataExchangeClient(binding);
     MetadataSet metadata = metadataExchangeClient.GetMetadata(address);
     WsdlImporter wsdlImporter = new WsdlImporter(metadata);
     //添加已知契约类型
     ContractDescription contract = ContractDescription.GetContract(typeof(ICalculator));
     wsdlImporter.KnownContracts.Add(new XmlQualifiedName(contract.Name, contract.Namespace), contract);
     ServiceEndpointCollection endpoints = wsdlImporter.ImportAllEndpoints();
     using (ChannelFactory<ICalculator> channelFactory = new ChannelFactory<ICalculator>(endpoints[0]))
     {
         ICalculator calculator = channelFactory.CreateChannel();
         Console.WriteLine("x + y = {2} when x = {0} and y = {1}", 1, 2, calculator.Add(1, 2));
     }
     Console.Read();
 }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:18,代码来源:Program.cs

示例13: Resolve

        public static ServiceEndpointCollection Resolve(IEnumerable<ContractDescription> contracts, Uri address, MetadataExchangeClientMode mode, MetadataExchangeClient client)
        {
            if (address == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("address");
            }
            MetadataExchangeClientModeHelper.Validate(mode);
            if (client == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("client");
            }
            if (contracts == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contracts");
            }
            ValidateContracts(contracts);

            MetadataSet metadataSet = client.GetMetadata(address, mode);
            return ImportEndpoints(metadataSet, contracts, client);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:20,代码来源:MetadataResolver.cs

示例14: ResolveWithWSMex

		static MetadataSet ResolveWithWSMex (string url)
		{
			MetadataSet metadata = null;
			try {
				var client = new MetadataExchangeClient (new EndpointAddress (url));

				Console.WriteLine ("\nAttempting to download metadata from {0} using WS-MetadataExchange..", url);
				metadata = client.GetMetadata ();
			} catch (InvalidOperationException e) {
				//MetadataExchangeClient wraps exceptions, thrown while
				//fetching the metadata, in an InvalidOperationException
				string msg;
				msg = e.InnerException == null ? e.Message : e.InnerException.ToString ();

				Console.WriteLine ("WS-MetadataExchange query failed for the url '{0}' with exception :\n {1}",
					url, msg);
			}

			return metadata;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:20,代码来源:WebServiceEngineWCF.cs

示例15: GenerateVBCodeForService

        static void GenerateVBCodeForService(EndpointAddress metadataAddress, string outputFile)
        {
          MetadataExchangeClient mexClient = new MetadataExchangeClient(metadataAddress);
          mexClient.ResolveMetadataReferences = true;
          MetadataSet metaDocs = mexClient.GetMetadata();

          WsdlImporter importer = new WsdlImporter(metaDocs);
          ServiceContractGenerator generator = new ServiceContractGenerator();

          // Uncomment the following code if you are going to do your work programmatically rather than add 
          // the WsdlDocumentationImporters through a configuration file. 
          /*
          // The following code inserts the custom WSDL programmatically adding the custom WsdlImporter without
          // removing the other importers already in the collection.
          System.Collections.Generic.IEnumerable<IWsdlImportExtension> exts = importer.WsdlExtensions;
          System.Collections.Generic.List<IWsdlImportExtension> newExts = new System.Collections.Generic.List<IWsdlImportExtension>();
          foreach (IWsdlImportExtension ext in exts)
            newExts.Add(ext);
          newExts.Add(new WsdlDocumentationImporter());
          importer = new WsdlImporter(newExts.ToArray(), metaDocs.MetadataSections);
          */

          System.Collections.ObjectModel.Collection<ContractDescription> contracts = importer.ImportAllContracts();
          foreach (ContractDescription contract in contracts)
          {
            generator.GenerateServiceContractType(contract);
          }
          if (generator.Errors.Count != 0)
            throw new ApplicationException("There were errors during code compilation.");

          // Write the code dom.
          System.CodeDom.Compiler.CodeGeneratorOptions options = new System.CodeDom.Compiler.CodeGeneratorOptions();
          options.BracingStyle = "C";
          System.CodeDom.Compiler.CodeDomProvider codeDomProvider = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("VB");
          System.CodeDom.Compiler.IndentedTextWriter textWriter = new System.CodeDom.Compiler.IndentedTextWriter(new System.IO.StreamWriter(outputFile));
          codeDomProvider.GenerateCodeFromCompileUnit(generator.TargetCompileUnit, textWriter, options);
          textWriter.Close();
        }
开发者ID:ssickles,项目名称:archive,代码行数:38,代码来源:client.cs


注:本文中的System.ServiceModel.Description.MetadataExchangeClient.GetMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。