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


C# Description.MetadataExchangeClient类代码示例

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


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

示例1: BeginResolve

    public static IAsyncResult BeginResolve(IEnumerable<ContractDescription> contracts, System.ServiceModel.EndpointAddress address, MetadataExchangeClient client, AsyncCallback callback, Object asyncState)
    {
      Contract.Requires(address != null);
      Contract.Ensures(Contract.Result<System.IAsyncResult>() != null);

      return default(IAsyncResult);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:System.ServiceModel.Description.MetadataResolver.cs

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: Main

        static void Main()
        {
            // Specify the Metadata Exchange binding and its security mode
            WSHttpBinding mexBinding = new WSHttpBinding(SecurityMode.Message);
            mexBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;

            // Create a MetadataExchangeClient for retrieving metadata, and set the certificate details
            MetadataExchangeClient mexClient = new MetadataExchangeClient(mexBinding);
            mexClient.SoapCredentials.ClientCertificate.SetCertificate(
                StoreLocation.CurrentUser, StoreName.My,
                X509FindType.FindBySubjectName, "client.com");
            mexClient.SoapCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
            mexClient.SoapCredentials.ServiceCertificate.SetDefaultCertificate(
                StoreLocation.CurrentUser, StoreName.TrustedPeople,
                X509FindType.FindBySubjectName, "localhost");

            // The contract we want to fetch metadata for
            Collection<ContractDescription> contracts = new Collection<ContractDescription>();
            ContractDescription contract = ContractDescription.GetContract(typeof(ICalculator));
            contracts.Add(contract);

            // Find endpoints for that contract
            EndpointAddress mexAddress = new EndpointAddress(ConfigurationManager.AppSettings["mexAddress"]);
            ServiceEndpointCollection endpoints = MetadataResolver.Resolve(contracts,
                mexAddress, mexClient);

            // Communicate with each endpoint that supports the ICalculator contract.
            foreach (ServiceEndpoint endpoint in endpoints)
            {
                if (endpoint.Contract.Namespace.Equals(contract.Namespace) && endpoint.Contract.Name.Equals(contract.Name))
                {
                    // Create a channel and set the certificate details to communicate with the Application endpoint
                    ChannelFactory<ICalculator> cf = new ChannelFactory<ICalculator>(endpoint.Binding, endpoint.Address);
                    cf.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My,
                        X509FindType.FindBySubjectName, "client.com");
                    cf.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;

                    ICalculator channel = cf.CreateChannel();

                    // call operations
                    DoCalculations(channel);

                    ((IChannel)channel).Close();
                    cf.Close();

                 }
            }

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
             
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:53,代码来源:metadataResolverClient.cs

示例11: 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

示例12: 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

示例13: BeginResolve

 public static IAsyncResult BeginResolve(IEnumerable<ContractDescription> contracts, EndpointAddress address, MetadataExchangeClient client, AsyncCallback callback, object asyncState)
 {
     if (address == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("address");
     }
     if (client == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("client");
     }
     if (contracts == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contracts");
     }
     ValidateContracts(contracts);
     return new AsyncMetadataResolverHelper(address, MetadataExchangeClientMode.MetadataExchange, client, contracts, callback, asyncState);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:MetadataResolver.cs

示例14: 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

示例15: 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


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