Export (0) Print
Expand All

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 sealed class DiscoveryExceptionDictionary : DictionaryBase
public final class DiscoveryExceptionDictionary extends DictionaryBase
public final class DiscoveryExceptionDictionary extends DictionaryBase
Not applicable.

The Errors property of DiscoveryClientProtocol is of type DiscoveryExceptionDictionary.

using System;
using System.Web.Services.Discovery;
using System.Xml;
using System.Collections;
using System.Runtime.Remoting;
using System.Net;

public class MySample
{
   static void Main()
   {
      string myDiscoFile = "http://localhost/MathService_cs.disco";
      string myUrlKey = "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 =
                                  (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 '" + 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.");

            Exception myException = myExceptionDictionary[myUrlKey];
            Console.WriteLine(" Source : " + myException.Source);
            Console.WriteLine(" Exception : " + 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("The requested service is not available.");
            myNewExceptionDictionary.Add(myUrlKey, myNewException);
            myExceptionDictionary = myNewExceptionDictionary;

            Console.WriteLine("Added exceptions.");

            object[] myArray = new object[myExceptionDictionary.Count];
            myExceptionDictionary.Keys.CopyTo((Array)myArray,0);
            Console.WriteLine(" Keys are :");
            foreach(object myObj in myArray)
            {
               Console.WriteLine(" " + myObj.ToString());
            }

            Console.WriteLine();

            object[] myCollectionArray = new object[myExceptionDictionary.Count];
            myExceptionDictionary.Values.CopyTo((Array)myCollectionArray,0);
            Console.WriteLine(" Values are :");
            foreach(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

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 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.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft