次の方法で共有


DiscoveryExceptionDictionary クラス

XML Web サービス探索中に発生した例外を収集します。このクラスは継承できません。

この型のすべてのメンバの一覧については、DiscoveryExceptionDictionary メンバ を参照してください。

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

NotInheritable Public Class DiscoveryExceptionDictionary
   Inherits DictionaryBase
[C#]
public sealed class DiscoveryExceptionDictionary : DictionaryBase
[C++]
public __gc __sealed class DiscoveryExceptionDictionary : public
   DictionaryBase
[JScript]
public class DiscoveryExceptionDictionary extends DictionaryBase

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

DiscoveryClientProtocolErrors プロパティが DiscoveryExceptionDictionary 型です。

使用例

 
Imports System
Imports System.Web.Services.Discovery
Imports System.Xml
Imports System.Collections
Imports System.Runtime.Remoting
Imports System.Net

Public Class MySample
   
   Shared Sub Main()
      Dim myDiscoFile As String = "https://localhost/MathService_vb.disco"
      Dim myUrlKey As String = "https://localhost/MathService_vb.asmx?wsdl"
      Dim myDiscoveryClientProtocol1 As New DiscoveryClientProtocol()
      Dim myDiscoveryDocument As DiscoveryDocument = myDiscoveryClientProtocol1.Discover(myDiscoFile)
      Dim myEnumerator As IEnumerator = myDiscoveryDocument.References.GetEnumerator()
      While myEnumerator.MoveNext()
         Dim myContractReference As ContractReference = CType(myEnumerator.Current, ContractReference)
         Dim myDiscoveryClientProtocol2 As DiscoveryClientProtocol = myContractReference.ClientProtocol
         myDiscoveryClientProtocol2.ResolveAll()
         Dim myExceptionDictionary As DiscoveryExceptionDictionary = myDiscoveryClientProtocol2.Errors
         If myExceptionDictionary.Contains(myUrlKey) = True Then
            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 + "'")
         End If
         If myExceptionDictionary.Contains(myUrlKey) = True Then
            Console.WriteLine("System generated exceptions.")
            
            Dim myException As Exception = 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)
            Dim myNewExceptionDictionary As New DiscoveryExceptionDictionary()
            ' Add an exception with the custom error message.
            Dim myNewException As New Exception("The requested service is not available.")
            myNewExceptionDictionary.Add(myUrlKey, myNewException)
            myExceptionDictionary = myNewExceptionDictionary
            Console.WriteLine("Added exceptions.")
            
            Dim myArray(myExceptionDictionary.Count -1 ) As Object
            myExceptionDictionary.Keys.CopyTo(CType(myArray, Array), 0)
            Console.WriteLine(" Keys are :")
            Dim myObj As Object
            For Each myObj In  myArray
               Console.WriteLine(" " + myObj.ToString())
            Next myObj
            Console.WriteLine()
            
            Dim myCollectionArray(myExceptionDictionary.Count -1 ) As Object
            myExceptionDictionary.Values.CopyTo(CType(myCollectionArray, Array), 0)
            Console.WriteLine(" Values are :")
            For Each myObj In  myCollectionArray
               Console.WriteLine(" " + myObj.ToString())
            Next myObj
         End If 
      End While
   End Sub 'Main
End Class 'MySample

[C#] 
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 = "https://localhost/MathService_cs.disco";
      string myUrlKey = "https://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());
            }
         }
      }
   }
}

[C++] 
#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"https://localhost/MathService_cs.disco";
   String* myUrlKey = S"https://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);
         }
      }
   }
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Web.Services.Discovery

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Web.Services (System.Web.Services.dll 内)

参照

DiscoveryExceptionDictionary メンバ | System.Web.Services.Discovery 名前空間 | Errors | DiscoveryClientProtocol | IDictionary | DictionaryBase