本文整理汇总了VB.NET中System.Web.Services.Discovery.DiscoveryExceptionDictionary类的典型用法代码示例。如果您正苦于以下问题:VB.NET DiscoveryExceptionDictionary类的具体用法?VB.NET DiscoveryExceptionDictionary怎么用?VB.NET DiscoveryExceptionDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DiscoveryExceptionDictionary类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MySample
' 导入命名空间
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 = "http://localhost/MathService_vb.disco"
Dim myUrlKey As String = "http://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
End Class