This documentation is archived and is not being maintained.

OperationFaultCollection Class

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

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

public ref class OperationFaultCollection sealed : public ServiceDescriptionBaseCollection

The OperationFault class corresponds to the Web Services Description Language (WSDL) <fault> element enclosed by the <operation> element that is in turn enclosed by the <portType> element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.

#using <System.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Web::Services::Description;
int main()
{
   try
   {
      // Read the StockQuote.wsdl file as input.
      ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote_cpp.wsdl" );

      PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes;
      PortType^ myPortType = myPortTypeCollection[ 0 ];
      OperationCollection^ myOperationCollection = myPortType->Operations;
      Operation^ myOperation = myOperationCollection[ 0 ];
      OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults;

      // Reverse the operation fault order. 
      if ( myOperationFaultCollection->Count > 1 )
      {
         OperationFault^ myOperationFault = myOperationFaultCollection[ 0 ];
         array<OperationFault^>^myOperationFaultArray = gcnew array<OperationFault^>(myOperationFaultCollection->Count);

         // Copy the operation fault to a temporary array.
         myOperationFaultCollection->CopyTo( myOperationFaultArray, 0 );

         // Remove all the operation faults from the collection. 
         for ( int i = 0; i < myOperationFaultArray->Length; i++ )
            myOperationFaultCollection->Remove( myOperationFaultArray[ i ] );

         // Insert the operation faults in the reverse order. 
         for ( int i = 0,j = (myOperationFaultArray->Length - 1); i < myOperationFaultArray->Length; i++,j-- )
            myOperationFaultCollection->Insert( i, myOperationFaultArray[ j ] );
         if ( myOperationFaultCollection->Contains( myOperationFault ) && (myOperationFaultCollection->IndexOf( myOperationFault ) == myOperationFaultCollection->Count - 1) )
                  Console::WriteLine( "Succeeded in reversing the operation faults." );
         else
                  Console::WriteLine( "Error while reversing the faults." );
      }

      BindingCollection^ myBindingCollection = myServiceDescription->Bindings;
      Binding^ myBinding = myBindingCollection[ 0 ];
      OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations;
      OperationBinding^ myOperationBinding = myOperationBindingCollection[ 0 ];
      FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults;

      // Reverse the fault binding order. 
      if ( myFaultBindingCollection->Count > 1 )
      {
         FaultBinding^ myFaultBinding = myFaultBindingCollection[ 0 ];
         array<FaultBinding^>^myFaultBindingArray = gcnew array<FaultBinding^>(myFaultBindingCollection->Count);

         // Copy the fault bindings to a temporary array.
         myFaultBindingCollection->CopyTo( myFaultBindingArray, 0 );

         // Remove all the fault bindings. 
         for ( int i = 0; i < myFaultBindingArray->Length; i++ )
            myFaultBindingCollection->Remove( myFaultBindingArray[ i ] );

         // Insert the fault bindings in the reverse order. 
         for ( int i = 0,j = (myFaultBindingArray->Length - 1); i < myFaultBindingArray->Length; i++,j-- )
            myFaultBindingCollection->Insert( i, myFaultBindingArray[ j ] );

         // Check whether the first element before the reversal  
         // is now the last element. 
         if ( myFaultBindingCollection->Contains( myFaultBinding ) && myFaultBindingCollection->IndexOf( myFaultBinding ) == (myFaultBindingCollection->Count - 1) )
         {
            // Write the WSDL generated to a file.
            myServiceDescription->Write( "StockQuoteOut_cpp.wsdl" );
            Console::WriteLine( "The file StockQuoteOut_cpp.wsdl was successfully written" );
         }
         else
            Console::WriteLine( "An error occured while reversing the input WSDL file." );
      }
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception caught!!!" );
      Console::WriteLine( "Source : {0}", e->Source );
      Console::WriteLine( "Message : {0}", e->Message );
   }
}
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Web::Services::Description;

int main() 
{
   try 
   {
      // Read the StockQuote.wsdl file as input.
      ServiceDescription * myServiceDescription = 
         ServiceDescription::Read(S"StockQuote_cpp.wsdl");
      PortTypeCollection * myPortTypeCollection = 
         myServiceDescription->PortTypes;
      PortType * myPortType = myPortTypeCollection->Item[0];
      OperationCollection * myOperationCollection = myPortType->Operations;
      Operation * myOperation = myOperationCollection->Item[0];
      OperationFaultCollection * myOperationFaultCollection =
         myOperation->Faults;

      // Reverse the operation fault order.
      if (myOperationFaultCollection->Count > 1) 
      {
         OperationFault * myOperationFault =
            myOperationFaultCollection->Item[0];
         OperationFault* myOperationFaultArray[] = 
            new OperationFault*[myOperationFaultCollection->Count];

         // Copy the operation fault to a temporary array.
         myOperationFaultCollection->CopyTo(myOperationFaultArray, 0);

         // Remove all the operation faults from the collection.
         for (int i = 0; i < myOperationFaultArray->Length; i++)
            myOperationFaultCollection->Remove(myOperationFaultArray->Item[i]);

         // Insert the operation faults in the reverse order.
         for (int i = 0, j = (myOperationFaultArray->Length - 1);
                  i < myOperationFaultArray->Length; i++, j--) 
            myOperationFaultCollection->Insert(
               i, myOperationFaultArray->Item[j]);

         if (myOperationFaultCollection->Contains(myOperationFault) &&
            (myOperationFaultCollection->IndexOf(myOperationFault)
            == myOperationFaultCollection->Count-1)) 
            Console::WriteLine(S"Succeeded in reversing the operation faults.");
         else
            Console::WriteLine(S"Error while reversing the faults.");
      }
      BindingCollection * myBindingCollection = 
         myServiceDescription->Bindings;
      Binding * myBinding = myBindingCollection->Item[0];
      OperationBindingCollection * myOperationBindingCollection =
         myBinding->Operations;
      OperationBinding * myOperationBinding =
         myOperationBindingCollection->Item[0];
      FaultBindingCollection * myFaultBindingCollection =
         myOperationBinding->Faults;

      // Reverse the fault binding order.
      if (myFaultBindingCollection->Count > 1) 
      {
         FaultBinding * myFaultBinding = myFaultBindingCollection->Item[0];

         FaultBinding* myFaultBindingArray[] = 
            new FaultBinding*[myFaultBindingCollection->Count];

         // Copy the fault bindings to a temporary array.
         myFaultBindingCollection->CopyTo(myFaultBindingArray, 0);

         // Remove all the fault bindings.
         for (int i = 0; i < myFaultBindingArray->Length; i++)
            myFaultBindingCollection->Remove(myFaultBindingArray->Item[i]);

         // Insert the fault bindings in the reverse order.
         for (int i = 0, j = (myFaultBindingArray->Length - 1);
            i < myFaultBindingArray->Length; i++, j--) 
            myFaultBindingCollection->Insert(i, myFaultBindingArray->Item[j]);

         // Check whether the first element before the reversal 
         // is now the last element.
         if (myFaultBindingCollection->Contains(myFaultBinding) &&
            myFaultBindingCollection->IndexOf(myFaultBinding) ==
            (myFaultBindingCollection->Count - 1)) 
         {
            // Write the WSDL generated to a file.
            myServiceDescription->Write(S"StockQuoteOut_cpp.wsdl");
            Console::WriteLine(
               S"The file StockQuoteOut_cpp.wsdl was successfully written");
         } 
         else
            Console::WriteLine(
               S"An error occured while reversing the input WSDL file.");
      }
   } 
   catch (Exception* e) 
   {
      Console::WriteLine(S"Exception caught!!!");
      Console::WriteLine(S"Source : {0}", e->Source);
      Console::WriteLine(S"Message : {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
Show: