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


C# Description.WsdlImporter类代码示例

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


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

示例1: Exception

		void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer,
			WsdlEndpointConversionContext context)
		{
			for (int i = 0; i < context.WsdlBinding.Extensions.Count; i ++) {
				if (context.WsdlBinding.Extensions [i] is SoapBinding) {
					SoapBinding transport = context.WsdlBinding.Extensions [i] as SoapBinding;
					if (transport.Transport != SoapBinding.HttpTransport)
						//FIXME: not http
						return;

					if (! (context.Endpoint.Binding is CustomBinding))
						//FIXME: 
						throw new Exception ();

					((CustomBinding) context.Endpoint.Binding).Elements.Add (new HttpTransportBindingElement ());
					//((CustomBinding) context.Endpoint.Binding).Scheme = "http";

					for (int j = 0; j < context.WsdlPort.Extensions.Count; j ++) {
						SoapAddressBinding address = context.WsdlPort.Extensions [j] as SoapAddressBinding;
						if (address == null)
							continue;

						context.Endpoint.Address = new EndpointAddress (address.Location);
						context.Endpoint.ListenUri = new Uri (address.Location);
					}

					break;
				}
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:30,代码来源:TransportBindingElementImporter.cs

示例2: ArgumentNullException

        void IWsdlImportExtension.ImportContract(WsdlImporter importer, WsdlContractConversionContext contractContext)
        {
            if (contractContext == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("contractContext"));

            MessageContractImporter.ImportMessageContract(importer, contractContext, MessageContractImporter.XmlSerializerSchemaImporter.Get(importer));
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:DataContractSerializerMessageContractImporter.cs

示例3: ArgumentNullException

		void IWsdlImportExtension.ImportContract (WsdlImporter importer,
			WsdlContractConversionContext context)
		{
			if (!enabled)
				return;

			if (importer == null)
				throw new ArgumentNullException ("importer");
			if (context == null)
				throw new ArgumentNullException ("context");
			if (this.importer != null || this.context != null)
				throw new SystemException ("INTERNAL ERROR: unexpected recursion of ImportContract method call");

			dc_importer = new XsdDataContractImporter ();
			schema_set_in_use = new XmlSchemaSet ();
			schema_set_in_use.Add (importer.XmlSchemas);
			foreach (WSDL wsdl in importer.WsdlDocuments)
				foreach (XmlSchema xs in wsdl.Types.Schemas)
					schema_set_in_use.Add (xs);

			// commenting out this import operation, but might be required (I guess not).
			//dc_importer.Import (schema_set_in_use);
			schema_set_in_use.Compile ();

			this.importer = importer;
			this.context = context;
			try {
				DoImportContract ();
			} finally {
				this.importer = null;
				this.context = null;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:DataContractSerializerMessageContractImporter.cs

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

示例5: NoExtensionsSetup

		void NoExtensionsSetup ()
		{
			XmlReaderSettings xs = new XmlReaderSettings ();
			xs.IgnoreWhitespace = true;
			xtr = XmlTextReader.Create ("Test/System.ServiceModel.Description/dump.xml", xs);

			xtr.Read ();

			//FIXME: skipping Headers
			while (xtr.LocalName != "Body") {
				if (!xtr.Read ())
					return;
			}

			//Move to <Metadata ..
			xtr.Read ();
			ms = MetadataSet.ReadFrom (xtr);

			//MyWsdlImportExtension mw = new MyWsdlImportExtension ();
			List<IWsdlImportExtension> list = new List<IWsdlImportExtension> ();
			//list.Add (mw);
			list.Add (new DataContractSerializerMessageContractImporter ());

			/*list.Add (new MessageEncodingBindingElementImporter ());
			list.Add (new TransportBindingElementImporter ());
			list.Add (new StandardBindingImporter ());*/

			wi = new WsdlImporter (ms, null, list);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:WsdlImporterTest.cs

示例6: GetBindingElements

        void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

#pragma warning suppress 56506 // [....], these properties cannot be null in this context
            if (context.Endpoint.Binding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding");
            }

#pragma warning suppress 56506 // [....], CustomBinding.Elements never be null
            TransportBindingElement transportBindingElement = GetBindingElements(context).Find<TransportBindingElement>();

            bool transportHandledExternaly = (transportBindingElement != null) && !StateHelper.IsRegisteredTransportBindingElement(importer, context);
            if (transportHandledExternaly)
                return;

#pragma warning suppress 56506 // [....], these properties cannot be null in this context
            WsdlNS.SoapBinding soapBinding = (WsdlNS.SoapBinding)context.WsdlBinding.Extensions.Find(typeof(WsdlNS.SoapBinding));
            if (soapBinding != null && transportBindingElement == null)
            {
                CreateLegacyTransportBindingElement(importer, soapBinding, context);
            }

            // Try to import WS-Addressing address from the port
            if (context.WsdlPort != null)
            {
                ImportAddress(context, transportBindingElement);
            }

        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:34,代码来源:TransportBindingElementImporter.cs

示例7: GenerateCodeDomTree

		private static void GenerateCodeDomTree(WsdlImporter wsdlImporter, ServiceContractGenerator contractGenerator)
		{
			Collection<ContractDescription> contracts = wsdlImporter.ImportAllContracts();
			Collection<Binding> bindings = wsdlImporter.ImportAllBindings();
			ServiceEndpointCollection endpoints = wsdlImporter.ImportAllEndpoints();

			if (wsdlImporter.Errors.Any(e => !e.IsWarning))
			{
				throw new CodeGenerationException(wsdlImporter.Errors);
			}

			foreach (ContractDescription contract in contracts)
			{
				//TODO:Alex:Make the naming scheme customisable.
				contract.Name = "I" + contract.Name.Replace("Interface", string.Empty);
				contractGenerator.GenerateServiceContractType(contract);
			}

			foreach (Binding binding in bindings)
			{
				string bindingSectionName, configurationName;
				contractGenerator.GenerateBinding(binding, out bindingSectionName, out configurationName);
			}

			foreach (ServiceEndpoint endpoint in endpoints)
			{
				ChannelEndpointElement channelElement;
				contractGenerator.GenerateServiceEndpoint(endpoint, out channelElement);
			}
		}
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:30,代码来源:CodeGenerator.cs

示例8: ImportMessageBinding

        static internal void ImportMessageBinding(WsdlImporter importer, WsdlEndpointConversionContext endpointContext, Type schemaImporterType)
        {
            // All the work is done in ImportMessageContract call
            bool isReferencedContract = IsReferencedContract(importer, endpointContext);

            MarkSoapExtensionsAsHandled(endpointContext.WsdlBinding);

            foreach (WsdlNS.OperationBinding wsdlOperationBinding in endpointContext.WsdlBinding.Operations)
            {
                OperationDescription operation = endpointContext.GetOperationDescription(wsdlOperationBinding);
                if (isReferencedContract || OperationHasBeenHandled(operation))
                {
                    MarkSoapExtensionsAsHandled(wsdlOperationBinding);

                    if (wsdlOperationBinding.Input != null)
                    {
                        MarkSoapExtensionsAsHandled(wsdlOperationBinding.Input);
                    }

                    if (wsdlOperationBinding.Output != null)
                    {
                        MarkSoapExtensionsAsHandled(wsdlOperationBinding.Output);
                    }

                    foreach (WsdlNS.MessageBinding wsdlMessageBinding in wsdlOperationBinding.Faults)
                    {
                        MarkSoapExtensionsAsHandled(wsdlMessageBinding);
                    }
                }
            }

        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:32,代码来源:MessageContractImporter.cs

示例9:

 void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
 {
     if (context != null && context.WsdlBinding != null && ContainsHttpBindingExtension(context.WsdlBinding))
     {
         httpBindingContracts.Add(context.ContractConversionContext.Contract);
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:HttpBindingExtension.cs

示例10: ArgumentNullException

		void IWsdlImportExtension.ImportContract (WsdlImporter importer,
			WsdlContractConversionContext context)
		{
			if (!enabled)
				return;

			if (importer == null)
				throw new ArgumentNullException ("importer");
			if (context == null)
				throw new ArgumentNullException ("context");
			if (this.importer != null || this.context != null)
				throw new SystemException ("INTERNAL ERROR: unexpected recursion of ImportContract method call");

#if USE_DATA_CONTRACT_IMPORTER
			dc_importer = new XsdDataContractImporter ();
			schema_set_in_use = new XmlSchemaSet ();
			schema_set_in_use.Add (importer.XmlSchemas);
			foreach (WSDL wsdl in importer.WsdlDocuments)
				foreach (XmlSchema xs in wsdl.Types.Schemas)
					schema_set_in_use.Add (xs);
			dc_importer.Import (schema_set_in_use);
#endif

			this.importer = importer;
			this.context = context;
			try {
				DoImportContract ();
			} finally {
				this.importer = null;
				this.context = null;
			}
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:32,代码来源:DataContractSerializerMessageContractImporter.cs

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

示例12: Generate

        static void Generate(string url, TextWriter writer)
        {
            var cr = new ContractReference();
            cr.Url = url;

            var protocol = new DiscoveryClientProtocol();

            var wc = new WebClient();
            using (var stream = wc.OpenRead(cr.Url))
                protocol.Documents.Add(cr.Url, cr.ReadDocument(stream));

            var mset = ToMetadataSet(protocol);

            var importer = new WsdlImporter(mset);
            var xsdImporter = new XsdDataContractImporter();
            var options = new ImportOptions();
            options.ReferencedCollectionTypes.Add(typeof(LinkedList<>));
            xsdImporter.Options = options;
            importer.State.Add(typeof(XsdDataContractImporter), xsdImporter);

            Collection<ContractDescription> contracts = importer.ImportAllContracts();

            CodeCompileUnit ccu = new CodeCompileUnit();
            CodeNamespace cns = new CodeNamespace("TestNamespace");
            ccu.Namespaces.Add(cns);

            var generator = new ServiceContractGenerator(ccu);

            foreach (var cd in contracts)
                generator.GenerateServiceContractType(cd);

            var provider = new CSharpCodeProvider();
            provider.GenerateCodeFromCompileUnit(ccu, writer, null);
        }
开发者ID:baulig,项目名称:Provcon-Faust,代码行数:34,代码来源:MainClass.cs

示例13: ImportEndpoint

		public void ImportEndpoint (WsdlImporter importer, WsdlEndpointConversionContext context)
		{
			// Only import the binding, not the endpoint.
			if (context.WsdlPort == null)
				return;
			
			DoImportEndpoint (context);
		}
开发者ID:rabink,项目名称:mono,代码行数:8,代码来源:TransportBindingElementImporter.cs

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

示例15:

		void IWsdlImportExtension.ImportEndpoint (WsdlImporter importer,
			WsdlEndpointConversionContext context)
		{
			if (!Enabled)
				return;

			impl.ImportEndpoint (importer, context);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:DataContractSerializerMessageContractImporter.cs


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