This documentation is archived and is not being maintained.

DiscoveryExceptionDictionary Class

Collects exceptions that occurred during XML Web services discovery. This class cannot be inherited.

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

public ref class DiscoveryExceptionDictionary sealed : public DictionaryBase

The Errors property of DiscoveryClientProtocol is of type DiscoveryExceptionDictionary.

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

using namespace System;
using namespace System::Web::Services::Discovery;
using namespace System::Xml;
using namespace System::Collections;
using namespace System::Runtime::Remoting;
using namespace System::Net;

int main()
{
   String^ myDiscoFile = "http://localhost/MathService_cs.disco";
   String^ myUrlKey = "http://localhost/MathService_cs.asmx?wsdl";
   DiscoveryClientProtocol^ myDiscoveryClientProtocol1 = gcnew DiscoveryClientProtocol;
   DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol1->Discover( myDiscoFile );
   IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator();
   while ( myEnumerator->MoveNext() )
   {
      ContractReference^ myContractReference = dynamic_cast<ContractReference^>(myEnumerator->Current);
      DiscoveryClientProtocol^ myDiscoveryClientProtocol2 = myContractReference->ClientProtocol;
      myDiscoveryClientProtocol2->ResolveAll();

      DiscoveryExceptionDictionary^ myExceptionDictionary = myDiscoveryClientProtocol2->Errors;
      if ( myExceptionDictionary->Contains( myUrlKey ) == true )
      {
         Console::WriteLine( "'myExceptionDictionary' contains a discovery exception for the key '{0}'", myUrlKey );
      }
      else
      {
         Console::WriteLine( "'myExceptionDictionary' does not contain a discovery exception for the key '{0}'", myUrlKey );
      }
      if ( myExceptionDictionary->Contains( myUrlKey ) == true )
      {
         Console::WriteLine( "System generated exceptions." );

         Exception^ myException = myExceptionDictionary[ myUrlKey ];
         Console::WriteLine( " Source : {0}", myException->Source );
         Console::WriteLine( " Exception : {0}", myException->Message );

         Console::WriteLine();

         // Remove the discovery exception.for the key 'myUrlKey'.
         myExceptionDictionary->Remove( myUrlKey );

         DiscoveryExceptionDictionary^ myNewExceptionDictionary = gcnew DiscoveryExceptionDictionary;

         // Add an exception with the custom error message.
         Exception^ myNewException = gcnew Exception( "The requested service is not available." );
         myNewExceptionDictionary->Add( myUrlKey, myNewException );
         myExceptionDictionary = myNewExceptionDictionary;

         Console::WriteLine( "Added exceptions." );

         array<Object^>^myArray = gcnew array<Object^>(myExceptionDictionary->Count);
         myExceptionDictionary->Keys->CopyTo( (Array^)myArray, 0 );
         Console::WriteLine( " Keys are :" );

         for each(Object^ myObj in myArray)
         {
            Console::WriteLine(" " + myObj->ToString());
         }

         Console::WriteLine();

         array<Object^>^myCollectionArray = gcnew array<Object^>(myExceptionDictionary->Count);
         myExceptionDictionary->Values->CopyTo( (Array^)myCollectionArray, 0 );
         Console::WriteLine( " Values are :" );
         for each(Object^ myObj in myCollectionArray)
         {
            Console::WriteLine(" " + myObj->ToString());
         }
      }
   }
}
#using <mscorlib.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>
using namespace System;
using namespace System::Web::Services::Discovery;
using namespace System::Xml;
using namespace System::Collections;
using namespace System::Runtime::Remoting;
using namespace System::Net;

int main()
{
   String* myDiscoFile = S"http://localhost/MathService_cs.disco";
   String* myUrlKey = S"http://localhost/MathService_cs.asmx?wsdl";
   DiscoveryClientProtocol* myDiscoveryClientProtocol1 =
      new DiscoveryClientProtocol();
   DiscoveryDocument* myDiscoveryDocument =
      myDiscoveryClientProtocol1->Discover(myDiscoFile);
   IEnumerator* myEnumerator =
      myDiscoveryDocument->References->GetEnumerator();
   while ( myEnumerator->MoveNext() )
   {
      ContractReference* myContractReference =
         dynamic_cast<ContractReference*>(myEnumerator->Current);
      DiscoveryClientProtocol* myDiscoveryClientProtocol2 =
         myContractReference->ClientProtocol;
      myDiscoveryClientProtocol2->ResolveAll();
      DiscoveryExceptionDictionary* myExceptionDictionary
         = myDiscoveryClientProtocol2->Errors;
      if ( myExceptionDictionary->Contains(myUrlKey) == true )
      {
         Console::WriteLine(S"'myExceptionDictionary' contains a discovery exception for the key '{0}'", myUrlKey );
      }
      else
      {
         Console::WriteLine(S"'myExceptionDictionary' does not contain a discovery exception for the key '{0}'", myUrlKey );
      }
      if (myExceptionDictionary->Contains(myUrlKey) == true )
      {
         Console::WriteLine(S"System generated exceptions.");

         Exception* myException = myExceptionDictionary->Item[myUrlKey];
         Console::WriteLine(S" Source : {0}", myException->Source);
         Console::WriteLine(S" Exception : {0}", myException->Message);

         Console::WriteLine();

         // Remove the discovery exception.for the key 'myUrlKey'.
         myExceptionDictionary->Remove(myUrlKey);

         DiscoveryExceptionDictionary* myNewExceptionDictionary =
            new DiscoveryExceptionDictionary();
         // Add an exception with the custom error message.
         Exception* myNewException =
            new Exception(S"The requested service is not available.");
         myNewExceptionDictionary->Add(myUrlKey, myNewException);
         myExceptionDictionary = myNewExceptionDictionary;

         Console::WriteLine(S"Added exceptions.");

         Object* myArray[] = new Object*[myExceptionDictionary->Count];
         myExceptionDictionary->Keys->CopyTo((Array*)myArray,0);
         Console::WriteLine(S" Keys are :");
         IEnumerator* myEnum = myArray->GetEnumerator();
         while (myEnum->MoveNext())
         {
            Object* myObj = __try_cast<Object*>(myEnum->Current);
            Console::WriteLine(S" {0}", myObj);
         }

         Console::WriteLine();

         Object* myCollectionArray[] = new Object*[myExceptionDictionary->Count];
         myExceptionDictionary->Values->CopyTo((Array*)myCollectionArray,0);
         Console::WriteLine(S" Values are :");
         IEnumerator* myEnum1 = myCollectionArray->GetEnumerator();
         while (myEnum1->MoveNext())
         {
            Object* myObj = __try_cast<Object*>(myEnum1->Current);
            Console::WriteLine(S" {0}", myObj);
         }
      }
   }
}

System::Object
  System.Collections::DictionaryBase
    System.Web.Services.Discovery::DiscoveryExceptionDictionary

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: