本文整理汇总了C#中System.ServiceModel.Description.WsdlImporter.ImportEndpoints方法的典型用法代码示例。如果您正苦于以下问题:C# WsdlImporter.ImportEndpoints方法的具体用法?C# WsdlImporter.ImportEndpoints怎么用?C# WsdlImporter.ImportEndpoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Description.WsdlImporter
的用法示例。
在下文中一共展示了WsdlImporter.ImportEndpoints方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportEndpoints
private static ServiceEndpointCollection ImportEndpoints(MetadataSet metadataSet, IEnumerable<ContractDescription> contracts, MetadataExchangeClient client)
{
ServiceEndpointCollection endpoints = new ServiceEndpointCollection();
WsdlImporter importer = new WsdlImporter(metadataSet);
importer.State.Add("MetadataExchangeClientKey", client);
foreach (ContractDescription description in contracts)
{
importer.KnownContracts.Add(WsdlExporter.WsdlNamingHelper.GetPortTypeQName(description), description);
}
foreach (ContractDescription description2 in contracts)
{
foreach (ServiceEndpoint endpoint in importer.ImportEndpoints(description2))
{
endpoints.Add(endpoint);
}
}
if (importer.Errors.Count > 0)
{
TraceWsdlImportErrors(importer);
}
return endpoints;
}
示例2: ImportWsdlPortType
ServiceEndpointCollection ImportWsdlPortType(XmlQualifiedName portTypeQName, WsdlImporter importer)
{
foreach (WsdlNS.ServiceDescription wsdl in importer.WsdlDocuments)
{
if (wsdl.TargetNamespace == portTypeQName.Namespace)
{
WsdlNS.PortType wsdlPortType = wsdl.PortTypes[portTypeQName.Name];
if (wsdlPortType != null)
{
ServiceEndpointCollection endpoints = importer.ImportEndpoints(wsdlPortType);
return endpoints;
}
}
}
return new ServiceEndpointCollection();
}
示例3: ImportEndpoints
private static ServiceEndpointCollection ImportEndpoints(MetadataSet metadataSet, IEnumerable<ContractDescription> contracts, MetadataExchangeClient client)
{
ServiceEndpointCollection endpoints = new ServiceEndpointCollection();
WsdlImporter importer = new WsdlImporter(metadataSet);
// remember the original proxy so user doesn't need to set it again
importer.State.Add(MetadataExchangeClient.MetadataExchangeClientKey, client);
foreach (ContractDescription cd in contracts)
{
importer.KnownContracts.Add(WsdlExporter.WsdlNamingHelper.GetPortTypeQName(cd), cd);
}
foreach (ContractDescription cd in contracts)
{
ServiceEndpointCollection contractEndpoints;
contractEndpoints = importer.ImportEndpoints(cd);
foreach (ServiceEndpoint se in contractEndpoints)
{
endpoints.Add(se);
}
}
//Trace all warnings and errors
if (importer.Errors.Count > 0)
{
TraceWsdlImportErrors(importer);
}
return endpoints;
}
示例4: ImportWsdlPortType
private ServiceEndpointCollection ImportWsdlPortType(XmlQualifiedName portTypeQName, WsdlImporter importer)
{
foreach (System.Web.Services.Description.ServiceDescription description in importer.WsdlDocuments)
{
if (description.TargetNamespace == portTypeQName.Namespace)
{
PortType wsdlPortType = description.PortTypes[portTypeQName.Name];
if (wsdlPortType != null)
{
return importer.ImportEndpoints(wsdlPortType);
}
}
}
return new ServiceEndpointCollection();
}
示例5: BasicHttpBinding_ImportEndpoints
public void BasicHttpBinding_ImportEndpoints ()
{
var label = new TestLabel ("BasicHttpBinding_ImportEndpoints");
var doc = TestContext.LoadMetadata ("BasicHttp");
var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
label.EnterScope ("wsdl");
Assert.That (sd.Bindings, Is.Not.Null, label.Get ());
Assert.That (sd.Bindings.Count, Is.EqualTo (1), label.Get ());
var binding = sd.Bindings [0];
Assert.That (sd.Services, Is.Not.Null, label.Get ());
Assert.That (sd.Services.Count, Is.EqualTo (1), label.Get ());
var service = sd.Services [0];
Assert.That (service.Ports, Is.Not.Null, label.Get ());
Assert.That (service.Ports.Count, Is.EqualTo (1), label.Get ());
var port = service.Ports [0];
Assert.That (sd.PortTypes, Is.Not.Null, label.Get ());
Assert.That (sd.PortTypes.Count, Is.EqualTo (1), label.Get ());
var portType = sd.PortTypes [0];
label.LeaveScope ();
var importer = new WsdlImporter (doc);
label.EnterScope ("by-service");
var byService = importer.ImportEndpoints (service);
BindingTestAssertions.CheckImportErrors (importer, label);
Assert.That (byService, Is.Not.Null, label.Get ());
Assert.That (byService.Count, Is.EqualTo (1), label.Get ());
label.LeaveScope ();
label.EnterScope ("by-binding");
var byBinding = importer.ImportEndpoints (binding);
BindingTestAssertions.CheckImportErrors (importer, label);
Assert.That (byBinding, Is.Not.Null, label.Get ());
Assert.That (byBinding.Count, Is.EqualTo (1), label.Get ());
label.LeaveScope ();
label.EnterScope ("by-port-type");
var byPortType = importer.ImportEndpoints (portType);
BindingTestAssertions.CheckImportErrors (importer, label);
Assert.That (byPortType, Is.Not.Null, label.Get ());
Assert.That (byPortType.Count, Is.EqualTo (1), label.Get ());
label.LeaveScope ();
}