This documentation is archived and is not being maintained.

ServiceDescriptionCollection Class

Represents a collection of instances of the ServiceDescription class. This class cannot be inherited.

For a list of all members of this type, see ServiceDescriptionCollection Members.

System.Object
   System.Collections.CollectionBase
      System.Web.Services.Description.ServiceDescriptionBaseCollection
         System.Web.Services.Description.ServiceDescriptionCollection

[Visual Basic]
NotInheritable Public Class ServiceDescriptionCollection
   Inherits ServiceDescriptionBaseCollection
[C#]
public sealed class ServiceDescriptionCollection :
   ServiceDescriptionBaseCollection
[C++]
public __gc __sealed class ServiceDescriptionCollection : public
   ServiceDescriptionBaseCollection
[JScript]
public class ServiceDescriptionCollection extends
   ServiceDescriptionBaseCollection

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Example

[Visual Basic] 
Imports System
Imports System.Xml
Imports System.Web.Services.Description

Class MyServiceDescriptionCollection
   
   Public Shared Sub Main()
      Try
         ' Get ServiceDescription objects.
         Dim myServiceDescription1 As ServiceDescription = _
            ServiceDescription.Read("DataTypes_VB.wsdl")
         Dim myServiceDescription2 As ServiceDescription = _
            ServiceDescription.Read("MathService_VB.wsdl")

         ' Set the names of the ServiceDescriptions.
         myServiceDescription1.Name = "DataTypes"
         myServiceDescription2.Name = "MathService"
         
         ' Create a ServiceDescriptionCollection.
         Dim myServiceDescriptionCollection As _
            New ServiceDescriptionCollection()
         
         ' Add the ServiceDescriptions to the collection. 
         myServiceDescriptionCollection.Add(myServiceDescription1)
         myServiceDescriptionCollection.Add(myServiceDescription2)
         
         ' Display the elements of the collection using the Item property.
         Console.WriteLine("Elements in the collection: ")
         Dim i As Integer
         For i = 0 To myServiceDescriptionCollection.Count - 1
            Console.WriteLine(myServiceDescriptionCollection(i).Name)
         Next i

         ' Construct an XML qualified name.
         Dim myXmlQualifiedName As New XmlQualifiedName( _
            "MathServiceSoap", "http://tempuri2.org/")
         
         ' Get the Binding from the collection.
         Dim myBinding As Binding =  _
            myServiceDescriptionCollection.GetBinding(myXmlQualifiedName)
         
         Console.WriteLine("Binding found in collection with name: " &  _
            myBinding.ServiceDescription.Name)
      Catch e As Exception
         Console.WriteLine("The following exception was raised: {0}", _
                 e.Message.ToString())
      End Try
   End Sub 'Main
End Class 'MyServiceDescriptionCollection

[C#] 
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);
      }
   }
}

[C++] 
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Xml;
using namespace System::Web::Services::Description;

int main() 
{
   try 
   {
      // Get ServiceDescription objects.
      ServiceDescription* myServiceDescription1 =
         ServiceDescription::Read(S"DataTypes_cpp.wsdl");
      ServiceDescription* myServiceDescription2 =
         ServiceDescription::Read(S"MathService_cpp.wsdl");

      // Set the names of the ServiceDescriptions.
      myServiceDescription1->Name = S"DataTypes";
      myServiceDescription2->Name = S"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 Item property.
      Console::WriteLine(S"Elements in the collection: ");
      for (int i=0; i<myServiceDescriptionCollection->Count; i++)
         Console::WriteLine(myServiceDescriptionCollection->Item[i]->Name);

      // Construct an XML qualified name.
      XmlQualifiedName* myXmlQualifiedName = 
         new XmlQualifiedName(S"MathServiceSoap", S"http://tempuri2.org/");

      // Get the Binding from the collection.
      Binding* myBinding =
         myServiceDescriptionCollection->GetBinding(myXmlQualifiedName);

      Console::WriteLine(S"Binding found in collection with name: {0}", 
         myBinding->ServiceDescription->Name);
   } 
   catch (Exception* e) 
   {
      Console::WriteLine(S"The following exception was raised: {0}", e->Message);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.Services.Description

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web.Services (in System.Web.Services.dll)

See Also

ServiceDescriptionCollection Members | System.Web.Services.Description Namespace

Show: