本文整理汇总了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");
}
示例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;
}
示例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");
}
示例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 ();
}
示例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);
}
示例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 ();
}
示例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");
}
示例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;
}
示例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");
}
示例10: WriteTo
void WriteTo (WsdlExporter we, string name)
{
using (XmlTextWriter xw = new XmlTextWriter (name, Encoding.UTF8)) {
xw.Formatting = Formatting.Indented;
we.GetGeneratedMetadata ().WriteTo (xw);
}
}
示例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 ();
}
示例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");
}
示例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);
}
示例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));
}
示例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();
}
}