DiscoveryExceptionDictionary Class
.NET Framework 2.0
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)
Assembly: System.Web.Services (in system.web.services.dll)
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()); } } } }
import System.*;
import System.Web.Services.Discovery.*;
import System.Xml.*;
import System.Collections.*;
import System.Runtime.Remoting.*;
import System.Net.*;
public class MySample
{
public static void main(String[] args)
{
String myDiscoFile = "http://localhost/MathService_jsl.disco";
String myUrlKey = "http://localhost/MathService_jsl.asmx?wsdl";
DiscoveryClientProtocol myDiscoveryClientProtocol1 =
new DiscoveryClientProtocol();
DiscoveryDocument myDiscoveryDocument = myDiscoveryClientProtocol1.
Discover(myDiscoFile);
IEnumerator myEnumerator = myDiscoveryDocument.
get_References().GetEnumerator();
while (myEnumerator.MoveNext()) {
ContractReference myContractReference = (ContractReference)
myEnumerator.get_Current();
DiscoveryClientProtocol myDiscoveryClientProtocol2 =
myContractReference.get_ClientProtocol();
myDiscoveryClientProtocol2.ResolveAll();
DiscoveryExceptionDictionary myExceptionDictionary =
myDiscoveryClientProtocol2.get_Errors();
if (myExceptionDictionary.Contains(myUrlKey) == true) {
Console.WriteLine("'myExceptionDictionary' contains "
+ " a discovery exception for the key '"
+ myUrlKey + "'");
}
else {
Console.WriteLine("'myExceptionDictionary' does not contain"
+ " a discovery exception for the key '"
+ myUrlKey + "'");
}
if (myExceptionDictionary.Contains(myUrlKey) == true) {
Console.WriteLine("System generated exceptions.");
System.Exception myException = myExceptionDictionary.
get_Item(myUrlKey);
Console.WriteLine(" Source : " + myException.get_Source());
Console.WriteLine(" Exception : " + myException.get_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("The requested service is not available.");
myNewExceptionDictionary.Add(myUrlKey, myNewException);
myExceptionDictionary = myNewExceptionDictionary;
Console.WriteLine("Added exceptions.");
Object myArray[] = new Object[myExceptionDictionary.
get_Count()];
myExceptionDictionary.get_Keys().CopyTo((Array)myArray, 0);
Console.WriteLine(" Keys are :");
Object myObj = null;
for ( int iCtr=0; iCtr < myArray.length; iCtr++ ) {
myObj = myArray[iCtr];
Console.WriteLine(" " + myObj.ToString());
}
Console.WriteLine();
Object myCollectionArray[] = new Object[myExceptionDictionary.
get_Count()];
myExceptionDictionary.get_Values().
CopyTo((Array)myCollectionArray, 0);
Console.WriteLine(" Values are :");
for (int iCtr = 0; iCtr < myCollectionArray.length; iCtr++) {
myObj = myCollectionArray[iCtr];
Console.WriteLine(" " + myObj.ToString());
}
}
}
} //main
} //MySample
System.Object
System.Collections.DictionaryBase
System.Web.Services.Discovery.DiscoveryExceptionDictionary
System.Collections.DictionaryBase
System.Web.Services.Discovery.DiscoveryExceptionDictionary
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: