This documentation is archived and is not being maintained.

ServiceDescriptionFormatExtensionCollection Class

Represents the collection of extensibility elements used by the XML Web service. This class cannot be inherited.

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

Public NotInheritable Class ServiceDescriptionFormatExtensionCollection _
	Inherits ServiceDescriptionBaseCollection
Dim instance As ServiceDescriptionFormatExtensionCollection

This collection can either contain instances of classes deriving from ServiceDescriptionFormatExtension, or instances of the XmlElement class. In a derived class, ServiceDescriptionFormatExtension class allows users to define extensibility elements in addition to those defined in the Web Services Description Language (WSDL) specification. Use these in your ServiceDescriptionFormatExtensionCollection if you know in advance the type of extensibility element you want to make. Use an XmlElement when you do not know the format of an element in advance.

Imports System
Imports System.Web.Services.Description
Imports System.Collections

Class MyFormatExtension
   Inherits ServiceDescriptionFormatExtension

   Public Sub New()
      ' Set the properties. 
      Me.Handled = True 
      Me.Required = True 
   End Sub 'New 
End Class 'MyFormatExtension

Class myCollectionSample

   Shared Sub Main()
         Dim myServiceDescription As ServiceDescription = _
         Dim myCollection As New ServiceDescriptionFormatExtensionCollection(myServiceDescription)
         Dim mySoapBinding1 As New SoapBinding()
         Dim mySoapBinding2 As New SoapBinding()
         Dim mySoapAddressBinding As New SoapAddressBinding()
         Dim myFormatExtensionObject As New MyFormatExtension()
         ' Add elements to collection.
         Console.WriteLine("Collection contains following types of elements: ")
         ' Display the 'Type' of the elements in collection. 
         Dim i As Integer 
         For i = 0 To myCollection.Count - 1
         Next i
         ' Check element of type 'SoapAddressBinding' in collection. 
         Dim myObj As Object = myCollection.Find(mySoapAddressBinding.GetType())
         If myObj Is Nothing Then
            Console.WriteLine("Element of type '{0}' not found in collection.", _
            Console.WriteLine("Element of type '{0}' found in collection.", _
         End If 
         ' Check all elements of type 'SoapBinding' in collection. 
         Dim myObjectArray1(myCollection.Count -1 ) As Object
         myObjectArray1 = myCollection.FindAll(mySoapBinding1.GetType())
         Dim myNumberOfElements As Integer = 0
         Dim myIEnumerator As IEnumerator = myObjectArray1.GetEnumerator()

         ' Calculate number of elements of type 'SoapBinding'. 
         While myIEnumerator.MoveNext()
            If mySoapBinding1.GetType() Is  myIEnumerator.Current.GetType() Then
               myNumberOfElements += 1
            End If 
         End While
         Console.WriteLine("Collection contains {0} objects of type '{1}'.", _
                 myNumberOfElements.ToString(), mySoapBinding1.GetType().ToString())
         ' Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsHandled' status for {0} object is {1}.", _
                 myFormatExtensionObject.ToString(), _
         ' Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsRequired' status for {0} object is {1}.", _
                 myFormatExtensionObject.ToString(), _
         ' Copy elements of collection to an Object array. 
         Dim myObjectArray2(myCollection.Count -1 ) As Object
         myCollection.CopyTo(myObjectArray2, 0)
         Console.WriteLine("Collection elements are copied to an object array.")
         ' Check for 'myFormatExtension' object in collection. 
         If myCollection.Contains(myFormatExtensionObject) Then 
            ' Get index of a 'myFormatExtension' object in collection.
            Console.WriteLine("Index of 'myFormatExtensionObject' is " + _
                 "{0} in collection.", myCollection.IndexOf(myFormatExtensionObject).ToString())
            ' Remove 'myFormatExtensionObject' element from collection.
            Console.WriteLine("'myFormatExtensionObject' is removed" + _
                 " from collection.")
         End If 
         ' Insert 'MyFormatExtension' object.
         myCollection.Insert(0, myFormatExtensionObject)
         Console.WriteLine("'myFormatExtensionObject' is inserted to collection.")
      Catch e As Exception
         Console.WriteLine("The following exception was raised: {0}", e.Message.ToString())
      End Try 
   End Sub 'Main
End Class 'myCollectionSample
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;

__gc class MyFormatExtension : public ServiceDescriptionFormatExtension 
      // Set the properties.
      this->Handled  = true;
      this->Required = true;
int main() 
      ServiceDescription* myServiceDescription =
      ServiceDescriptionFormatExtensionCollection* myCollection = new ServiceDescriptionFormatExtensionCollection(myServiceDescription);
      SoapBinding* mySoapBinding1 = new SoapBinding();
      SoapBinding* mySoapBinding2 = new SoapBinding();
      SoapAddressBinding* mySoapAddressBinding = new SoapAddressBinding();
      MyFormatExtension* myFormatExtensionObject = new MyFormatExtension();
      // Add elements to collection.
      Console::WriteLine(S"Collection contains following types of elements: ");
      // Display the 'Type' of the elements in collection.
      for (int i = 0;i< myCollection->Count;i++) 

      // Check element of type 'SoapAddressBinding' in collection.
      Object*   myObj = myCollection->Find(mySoapAddressBinding->GetType());
      if (myObj == 0) 
         Console::WriteLine(S"Element of type ' {0}' not found in collection.",
         Console::WriteLine(S"Element of type ' {0}' found in collection.",
      // Check all elements of type 'SoapBinding' in collection.
      Object* myObjectArray1[] = new Object*[myCollection->Count];
      myObjectArray1 = myCollection->FindAll(mySoapBinding1->GetType());
      int myNumberOfElements = 0;
      IEnumerator* myIEnumerator  = myObjectArray1->GetEnumerator();

      // Calculate number of elements of type 'SoapBinding'.
         if (mySoapBinding1->GetType() == myIEnumerator->Current->GetType())
      Console::WriteLine(S"Collection contains {0} objects of type ' {1}'.",
      // Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
      Console::WriteLine(S"'IsHandled' status for {0} object is {1}.",
      // Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
      Console::WriteLine(S"'IsRequired' status for {0} object is {1}.",
      // Copy elements of collection to an Object array.
      Object* myObjectArray2[] = new Object*[myCollection->Count];
      myCollection->CopyTo(myObjectArray2, 0);
      Console::WriteLine(S"Collection elements are copied to an object array.");
      // Check for 'myFormatExtension' object in collection.
      if (myCollection->Contains(myFormatExtensionObject)) 
         // Get index of a 'myFormatExtension' object in collection.
         Console::WriteLine(S"Index of 'myFormatExtensionObject' is {0} in collection.",
         // Remove 'myFormatExtensionObject' element from collection.
         Console::WriteLine(S"'myFormatExtensionObject' is removed  from collection.");
      // Insert 'MyFormatExtension' object.
      myCollection->Insert(0, myFormatExtensionObject);
      Console::WriteLine(S"'myFormatExtensionObject' is inserted to collection.");

   catch (Exception* e) 
      Console::WriteLine(S"The following exception was raised: {0}", e->Message);


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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0