本文整理汇总了C#中System.Web.Services.Description.ServiceDescriptionCollection类的典型用法代码示例。如果您正苦于以下问题:C# ServiceDescriptionCollection类的具体用法?C# ServiceDescriptionCollection怎么用?C# ServiceDescriptionCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceDescriptionCollection类属于System.Web.Services.Description命名空间,在下文中一共展示了ServiceDescriptionCollection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Xml;
using System.Web.Services.Description;
class MyServiceDescriptionCollection
{
public static void Main()
{
try
{
// Get ServiceDescription objects.
ServiceDescription myServiceDescription1 =
ServiceDescription.Read("DataTypes_CS.wsdl");
ServiceDescription myServiceDescription2 =
ServiceDescription.Read("MathService_CS.wsdl");
// Set the names of the ServiceDescriptions.
myServiceDescription1.Name = "DataTypes";
myServiceDescription2.Name = "MathService";
// Create a ServiceDescriptionCollection.
ServiceDescriptionCollection myServiceDescriptionCollection =
new ServiceDescriptionCollection();
// Add the ServiceDescriptions to the collection.
myServiceDescriptionCollection.Add(myServiceDescription1);
myServiceDescriptionCollection.Add(myServiceDescription2);
// Display the elements of the collection using the indexer.
Console.WriteLine("Elements in the collection: ");
for(int i = 0; i < myServiceDescriptionCollection.Count; i++)
{
Console.WriteLine(myServiceDescriptionCollection[i].Name);
}
// Construct an XML qualified name.
XmlQualifiedName myXmlQualifiedName =
new XmlQualifiedName("MathServiceSoap", "http://tempuri2.org/");
// Get the Binding from the collection.
Binding myBinding =
myServiceDescriptionCollection.GetBinding(myXmlQualifiedName);
Console.WriteLine("Binding found in collection with name: " +
myBinding.ServiceDescription.Name);
}
catch(Exception e)
{
Console.WriteLine("The following exception was raised: {0}", e.Message);
}
}
}