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


C# WsdlExporter.GetGeneratedMetadata方法代码示例

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


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

示例1: ExportEndpointTest

		public void ExportEndpointTest ()
		{
			WsdlExporter we = new WsdlExporter ();

			ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
			se.Binding = new BasicHttpBinding ();
			se.Address = new EndpointAddress ("http://localhost:8080");
			//TEST Invalid name: 5se.Name = "Service#1";
			//se.Name = "Service0";
			//se.ListenUri = new Uri ("http://localhost:8080/svc");

			we.ExportEndpoint (se);

			MetadataSet ms = we.GetGeneratedMetadata ();
			Assert.AreEqual (6, ms.MetadataSections.Count);
			CheckContract_IEchoService (ms, "#eet01");

			WSServiceDescription sd = GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest");
			CheckServicePort (GetService (sd, "service", "ExportEndpointTest"),
				"BasicHttpBinding_IEchoService", new XmlQualifiedName ("BasicHttpBinding_IEchoService", "http://tempuri.org/"),
				"http://localhost:8080/", "#eet02");

			CheckBasicHttpBinding (sd, "BasicHttpBinding_IEchoService", new XmlQualifiedName ("IEchoService", "http://myns/echo"),
				"Echo", "http://myns/echo/IEchoService/Echo", true, true, "#eet03");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:WsdlExporterTest.cs

示例2: ExportEndpoints

        private XmlDocument ExportEndpoints()
        {
            WsdlExporter exporter = new WsdlExporter();
            foreach (ServiceEndpoint ep in endpoints)
            {
                exporter.ExportEndpoint(ep);
            }

            MetadataSet metadataSet = exporter.GetGeneratedMetadata();
            StringBuilder b = new StringBuilder();
            StringWriter sw = new StringWriter(b);
            XmlTextWriter tw = new XmlTextWriter(sw);
            foreach (MetadataSection section in metadataSet.MetadataSections)
            {
                if (section.Metadata is System.Web.Services.Description.ServiceDescription)
                {
                    System.Web.Services.Description.ServiceDescription sd = (System.Web.Services.Description.ServiceDescription)section.Metadata;
                    sd.Write(tw);
                }
            }

            string wcfWsdl = b.ToString();
            // Read it in to an XmlDocument.
            XmlDocument wcfWsdlDoc = new XmlDocument();
            wcfWsdlDoc.LoadXml(wcfWsdl);
            return wcfWsdlDoc;
        }
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:27,代码来源:WsdlWorkshop.cs

示例3: Ctor1

		public void Ctor1 ()
		{
			WsdlExporter we = new WsdlExporter ();

			Assert.IsNotNull (we.GetGeneratedMetadata ());
			Assert.IsNotNull (we.GeneratedWsdlDocuments, "#c1");
			Assert.AreEqual (0, we.GeneratedWsdlDocuments.Count, "#c2");

			Assert.IsNotNull (we.GeneratedXmlSchemas, "#c3");
			Assert.AreEqual (0, we.GeneratedXmlSchemas.Count, "#c4");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:WsdlExporterTest.cs

示例4: BasicHttp

		public static MetadataSet BasicHttp ()
		{
			var exporter = new WsdlExporter ();
			
			var cd = new ContractDescription ("MyContract");
			
			exporter.ExportEndpoint (new ServiceEndpoint (
				cd, new BasicHttpBinding (), new EndpointAddress (HttpUri)));
			
			return exporter.GetGeneratedMetadata ();
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:11,代码来源:MetadataSamples.cs

示例5: Generate

 public static Wsdl Generate(Type contract)
 {
     var exporter = new WsdlExporter();
     exporter.ExportContract(ContractDescription.GetContract(contract));
     var metadataSet = exporter.GetGeneratedMetadata();
     var schemaStream = new MemoryStream();
     metadataSet.WriteTo(new XmlTextWriter(new StreamWriter(schemaStream)));
     schemaStream.Position = 0;
     var source = XDocument.Load(
         new XmlTextReader(schemaStream));
     return new Wsdl(source);
 }
开发者ID:huoxudong125,项目名称:WCFDoc,代码行数:12,代码来源:Wsdl.cs

示例6: BasicHttp_TransportSecurity

		public static MetadataSet BasicHttp_TransportSecurity ()
		{
			var exporter = new WsdlExporter ();
			
			var cd = new ContractDescription ("MyContract");
			
			var binding = new BasicHttpBinding ();
			binding.Security.Mode = BasicHttpSecurityMode.Transport;
			
			exporter.ExportEndpoint (new ServiceEndpoint (
				cd, binding, new EndpointAddress (HttpUri)));
			
			return exporter.GetGeneratedMetadata ();
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:14,代码来源:MetadataSamples.cs

示例7: Main

 static void Main(string[] args)
 {
     ContractDescription contract = ContractDescription.GetContract(typeof(IOrderService));
     EndpointAddress address1 = new EndpointAddress("http://127.0.0.1/orderservice");
     EndpointAddress address2 = new EndpointAddress("net.tcp://127.0.0.1/orderservice");
     ServiceEndpoint endpoint1 = new ServiceEndpoint(contract, new WS2007HttpBinding(), address1);
     ServiceEndpoint endpoint2 = new ServiceEndpoint(contract, new NetTcpBinding(), address2);
     XmlQualifiedName serviceName = new XmlQualifiedName("OrderService", "http://www.artech.com/services/");
     WsdlExporter exporter = new WsdlExporter();
     exporter.ExportEndpoints(new ServiceEndpoint[] { endpoint1, endpoint2 }, serviceName);
     MetadataSet metadata = exporter.GetGeneratedMetadata();
     using (XmlWriter writer = new XmlTextWriter("metadata.xml", Encoding.UTF8))
     {
         metadata.WriteTo(writer);
     }
     Process.Start("metadata.xml");
 }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:17,代码来源:Program.cs

示例8: GetExportedMetadata

 private static MetadataSet GetExportedMetadata(ServiceDescription serviceDescription)
 {
     Collection<ServiceEndpoint> endpoints = new Collection<ServiceEndpoint>();
     foreach (var endpoint in serviceDescription.Endpoints)
     {
         if (endpoint.Contract.ContractType == typeof(IMetadataProvisionService))
         {
             continue;
         }
         ServiceEndpoint newEndpoint = new ServiceEndpoint(endpoint.Contract, endpoint.Binding, endpoint.Address);
         newEndpoint.Name = endpoint.Name;
         foreach (var behavior in endpoint.Behaviors)
         {
             newEndpoint.Behaviors.Add(behavior);
         }
         endpoints.Add(newEndpoint);
     }
     WsdlExporter exporter = new WsdlExporter();
     XmlQualifiedName wsdlServiceQName = new XmlQualifiedName(serviceDescription.Name, serviceDescription.Namespace);
     exporter.ExportEndpoints(endpoints, wsdlServiceQName);
     MetadataSet metadata = exporter.GetGeneratedMetadata();
     return metadata;
 }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:23,代码来源:ServiceMetadataBehaviorAttribute.cs

示例9: ExportEndpointTest5

		public void ExportEndpointTest5 () {
			WsdlExporter we = new WsdlExporter ();

			ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
			se.Binding = new BasicHttpBinding ();
			se.Address = new EndpointAddress ("http://localhost:8080");

			we.ExportEndpoint (se);

			MetadataSet ms = we.GetGeneratedMetadata ();
			Assert.AreEqual (6, ms.MetadataSections.Count);
			WSServiceDescription wsd = GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest5#1");

			SoapBinding soapBinding = (SoapBinding) wsd.Bindings [0].Extensions [0];
			Assert.AreEqual (SoapBindingStyle.Document, soapBinding.Style, "soapBinding.Style");
			Assert.AreEqual (SoapBinding.HttpTransport, soapBinding.Transport, "soapBinding.Transport");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:WsdlExporterTest.cs

示例10: WriteTo

		void WriteTo (WsdlExporter we, string name)
		{
			using (XmlTextWriter xw = new XmlTextWriter (name, Encoding.UTF8)) {
				xw.Formatting = Formatting.Indented;
				we.GetGeneratedMetadata ().WriteTo (xw);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:WsdlExporterTest.cs

示例11: NetTcp_MessageSecurity

		public static MetadataSet NetTcp_MessageSecurity ()
		{
			var exporter = new WsdlExporter ();
			
			var cd = new ContractDescription ("MyContract");
			
			exporter.ExportEndpoint (new ServiceEndpoint (
				cd, new NetTcpBinding (SecurityMode.Message, false),
				new EndpointAddress (NetTcpUri)));
			
			return exporter.GetGeneratedMetadata ();
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:12,代码来源:MetadataSamples.cs

示例12: ExportMexContract

		//FIXME: One check not working, BeginGetResult
		public void ExportMexContract ()
		{
			WsdlExporter we = new WsdlExporter ();
			ContractDescription cd = ContractDescription.GetContract (typeof (IMetadataExchange));
			we.ExportContract (cd);

			MetadataSet ms = we.GetGeneratedMetadata ();

			WSServiceDescription sd = GetServiceDescription (ms, "http://schemas.microsoft.com/2006/04/mex", "ExportMexContract");

			CheckMessage (sd, "IMetadataExchange_Get_InputMessage", "request", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc0");
			CheckMessage (sd, "IMetadataExchange_Get_OutputMessage", "GetResult", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc1");

			//PortType
			PortType port_type = sd.PortTypes ["IMetadataExchange"];
			Assert.IsNotNull (port_type, "#exc2, PortType named IMetadataExchange not found.");

			Assert.AreEqual (1, port_type.Operations.Count, "#exc3");
			Operation op = port_type.Operations [0];
			Assert.AreEqual ("Get", op.Name, "#exc4");

			Assert.AreEqual (2, op.Messages.Count, "#exc5");
			CheckOperationMessage (op.Messages [0], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_InputMessage", 
				typeof (OperationInput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");
			
			CheckOperationMessage (op.Messages [1], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_OutputMessage", 
				typeof (OperationOutput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse");

			CheckSpecialMessage (ms, "#exc6");

			Assert.AreEqual (1, we.GeneratedWsdlDocuments.Count, "GeneratedWsdlDocuments.Count");
			Assert.AreEqual (1, we.GeneratedXmlSchemas.Count, "GeneratedXmlSchemas.Count");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:34,代码来源:WsdlExporterTest.cs

示例13: ExportContract2

		public void ExportContract2 ()
		{
			WsdlExporter we = new WsdlExporter ();
			we.ExportContract (ContractDescription.GetContract (typeof (IFoo1)));

			MetadataSet ms = we.GetGeneratedMetadata ();
			Assert.AreEqual (5, ms.MetadataSections.Count);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:WsdlExporterTest.cs

示例14: ExportMetadata

		private static void ExportMetadata(ServiceEndpoint endpoint, EndpointDiscoveryBehavior discovery)
		{
			var exporter = new WsdlExporter();
			exporter.ExportEndpoint(endpoint);
			var metadata = exporter.GetGeneratedMetadata();

			var document = new XDocument();
			using (var xmlWriter = document.CreateWriter())
			{
				xmlWriter.WriteStartElement(WcfConstants.EndpointMetadata.LocalName, 
											WcfConstants.EndpointMetadata.Namespace.NamespaceName);
				metadata.WriteTo(xmlWriter);
				xmlWriter.WriteEndElement();
				xmlWriter.Flush();
			}

			discovery.Extensions.Add(document.Element(WcfConstants.EndpointMetadata));
		}
开发者ID:codereflection,项目名称:Castle.Facilities.Wcf,代码行数:18,代码来源:WcfDiscoveryExtension.cs

示例15: Main

        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(WcfServiceLibrary1.Service1)))
            {
                // surrogate definition..
                foreach (ServiceEndpoint ep in host.Description.Endpoints)
                {
                    foreach (OperationDescription op in ep.Contract.Operations)
                    {
                        DataContractSerializerOperationBehavior dataContractBehavior =
                            op.Behaviors.Find<DataContractSerializerOperationBehavior>()
                            as DataContractSerializerOperationBehavior;
                        if (dataContractBehavior != null)
                        {
                            dataContractBehavior.DataContractSurrogate = new valToTransferAsBytes();
                        }
                        else
                        {
                            dataContractBehavior = new DataContractSerializerOperationBehavior(op);
                            dataContractBehavior.DataContractSurrogate = new valToTransferAsBytes();
                            op.Behaviors.Add(dataContractBehavior);
                        }
                    }
                }

                // set up exporter with surrogate definition..
                WsdlExporter exporter = new WsdlExporter();
                object dataContractExporter;
                XsdDataContractExporter xsdInventoryExporter;
                if (!exporter.State.TryGetValue(typeof(XsdDataContractExporter),
                    out dataContractExporter))
                {
                    xsdInventoryExporter = new XsdDataContractExporter(exporter.GeneratedXmlSchemas);
                }
                else
                    xsdInventoryExporter = (XsdDataContractExporter)dataContractExporter;
                exporter.State.Add(typeof(XsdDataContractExporter), xsdInventoryExporter);


                if (xsdInventoryExporter.Options == null)
                    xsdInventoryExporter.Options = new ExportOptions();
                xsdInventoryExporter.Options.DataContractSurrogate = new valToTransferAsBytes();

                // export the endpoints..

                

                ServiceEndpointCollection sec = host.Description.Endpoints;
                foreach (ServiceEndpoint se in sec)
                {
                    Console.WriteLine(se.Name);
                    exporter.ExportEndpoint(se);
                }

                MetadataSet docs = null;
                docs = exporter.GetGeneratedMetadata();

                host.Description.


                host.Open();

                PrintDescription(host);

                Console.WriteLine("The Trading Service is available.  Press any key to exit.");
                Console.ReadKey();

                host.Close();
            }

        }
开发者ID:ehershey,项目名称:development,代码行数:71,代码来源:Program.cs


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