DiscoveryClientProtocol.Errors 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得來自這個類別的方法引動過程期間所發生的例外狀況 (Exception) 集合。
public:
property System::Web::Services::Discovery::DiscoveryExceptionDictionary ^ Errors { System::Web::Services::Discovery::DiscoveryExceptionDictionary ^ get(); };
public System.Web.Services.Discovery.DiscoveryExceptionDictionary Errors { get; }
member this.Errors : System.Web.Services.Discovery.DiscoveryExceptionDictionary
Public ReadOnly Property Errors As DiscoveryExceptionDictionary
屬性值
例外狀況的 DiscoveryExceptionDictionary。
範例
String^ myDiscoFile = "http://localhost/MathService_cs.vsdisco";
String^ myUrlKey = "http://localhost/MathService_cs.asmx?wsdl";
DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol;
// Get the discovery document.
DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol->Discover( myDiscoFile );
IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator();
while ( myEnumerator->MoveNext() )
{
ContractReference^ myContractReference = dynamic_cast<ContractReference^>(myEnumerator->Current);
// Get the DiscoveryClientProtocol from the ContractReference.
myDiscoveryClientProtocol = myContractReference->ClientProtocol;
myDiscoveryClientProtocol->ResolveAll();
DiscoveryExceptionDictionary^ myExceptionDictionary = myDiscoveryClientProtocol->Errors;
if ( myExceptionDictionary->Contains( myUrlKey ) )
{
Console::WriteLine( "System generated exceptions." );
// Get the exception from the DiscoveryExceptionDictionary.
Exception^ myException = myExceptionDictionary[ myUrlKey ];
Console::WriteLine( " Source : {0}", myException->Source );
Console::WriteLine( " Exception : {0}", myException->Message );
}
}
}
string myDiscoFile = "http://localhost/MathService_cs.vsdisco";
string myUrlKey = "http://localhost/MathService_cs.asmx?wsdl";
DiscoveryClientProtocol myDiscoveryClientProtocol =
new DiscoveryClientProtocol();
// Get the discovery document.
DiscoveryDocument myDiscoveryDocument =
myDiscoveryClientProtocol.Discover(myDiscoFile);
IEnumerator myEnumerator =
myDiscoveryDocument.References.GetEnumerator();
while ( myEnumerator.MoveNext() )
{
ContractReference myContractReference =
(ContractReference)myEnumerator.Current;
// Get the DiscoveryClientProtocol from the ContractReference.
myDiscoveryClientProtocol = myContractReference.ClientProtocol;
myDiscoveryClientProtocol.ResolveAll();
DiscoveryExceptionDictionary myExceptionDictionary
= myDiscoveryClientProtocol.Errors;
if (myExceptionDictionary.Contains(myUrlKey))
{
Console.WriteLine("System generated exceptions.");
// Get the exception from the DiscoveryExceptionDictionary.
Exception myException = myExceptionDictionary[myUrlKey];
Console.WriteLine(" Source : " + myException.Source);
Console.WriteLine(" Exception : " + myException.Message);
}
}
Dim myDiscoFile As String = "http://localhost/MathService_vb.vsdisco"
Dim myUrlKey As String = "http://localhost/MathService_vb.asmx?wsdl"
Dim myDiscoveryClientProtocol As New DiscoveryClientProtocol()
' Get the discovery document.
Dim myDiscoveryDocument As DiscoveryDocument = myDiscoveryClientProtocol.Discover(myDiscoFile)
Dim myEnumerator As IEnumerator = myDiscoveryDocument.References.GetEnumerator()
While myEnumerator.MoveNext()
Dim myContractReference As ContractReference = CType(myEnumerator.Current, ContractReference)
' Get the DiscoveryClientProtocol from the ContractReference.
myDiscoveryClientProtocol = myContractReference.ClientProtocol
myDiscoveryClientProtocol.ResolveAll()
Dim myExceptionDictionary As DiscoveryExceptionDictionary = myDiscoveryClientProtocol.Errors
If myExceptionDictionary.Contains(myUrlKey) Then
Console.WriteLine("System generated exceptions.")
' Get the exception from the DiscoveryExceptionDictionary.
Dim myException As Exception = myExceptionDictionary(myUrlKey)
Console.WriteLine(" Source : " & myException.Source)
Console.WriteLine(" Exception : " & myException.Message)
Console.WriteLine()
End If
End While
備註
Errors集合會填入叫 Discover 用 、 DiscoverAny 、 ResolveAll 和 ResolveOneLevel 方法期間發生的例外狀況。 會在 DiscoveryExceptionDictionary 叫用這些方法時清除 。