本文整理匯總了VB.NET中System.Web.Services.Discovery.DiscoveryReference類的典型用法代碼示例。如果您正苦於以下問題:VB.NET DiscoveryReference類的具體用法?VB.NET DiscoveryReference怎麽用?VB.NET DiscoveryReference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DiscoveryReference類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: MyDiscoveryDocumentClass
' 導入命名空間
Imports System.IO
Imports System.Web.Services.Discovery
Imports System.Net
Class MyDiscoveryDocumentClass
Public Shared Sub Main()
Try
Dim myDiscoveryDocument As DiscoveryDocument
Dim myStreamReader As New StreamReader("c:\Inetpub\wwwroot\dataservice.disco")
Dim myStream As New FileStream("c:\MyDiscovery.disco", FileMode.OpenOrCreate)
Console.WriteLine("Demonstrating DiscoveryReference class.")
' Read the discovery file.
myDiscoveryDocument = DiscoveryDocument.Read(myStreamReader)
' Create an instance of the DiscoveryReference class.
Dim myDiscoveryReference As MyDiscoveryReferenceClass
myDiscoveryReference = New MyDiscoveryReferenceClass()
Dim myDiscoveryClientProtocol As New DiscoveryClientProtocol()
myDiscoveryClientProtocol.Credentials = _
CredentialCache.DefaultCredentials
' Set the client protocol.
myDiscoveryReference.ClientProtocol = myDiscoveryClientProtocol
' Read the default file name.
Console.WriteLine("Default file name is: " _
& myDiscoveryReference.DefaultFilename)
' Write the document.
myDiscoveryReference.WriteDocument(myDiscoveryDocument, myStream)
' Read the document.
myDiscoveryReference.ReadDocument(myStream)
' Set the URL.
myDiscoveryReference.Url = "http://localhost/dataservice.disco"
Console.WriteLine("Url is : " + myDiscoveryReference.Url)
' Resolve the URL.
myDiscoveryReference.Resolve()
myStreamReader.Close()
myStream.Close()
Catch e as Exception
Console.WriteLine("Exception caught! - {0}", e.Message)
End Try
End Sub
End Class
' Class derived from DiscoveryReference class and overriding it members.
Class MyDiscoveryReferenceClass
Inherits DiscoveryReference
Private myDocumentUrl As String
Public Overrides ReadOnly Property DefaultFilename() As String
Get
Return "dataservice.disco"
End Get
End Property
Public Overrides Function _
ReadDocument(ByVal stream As System.IO.Stream) As Object
Return stream
End Function
Public Overloads Sub Resolve()
Try
Dim myDiscoveryRefDocument As DiscoveryDocument
myDiscoveryRefDocument = MyBase.ClientProtocol.Discover(Url)
Catch e As Exception
Throw e
End Try
End Sub
Protected Overloads Overrides Sub _
Resolve(ByVal contentType As String, ByVal stream As Stream)
End Sub
Public Overrides Property Url() As String
Get
Return myDocumentUrl
End Get
Set(ByVal Value As String)
myDocumentUrl = Value
End Set
End Property
Public Overrides Sub WriteDocument _
(ByVal document As Object, ByVal stream As System.IO.Stream)
Dim myDiscoveryDocument As DiscoveryDocument = _
CType(document, DiscoveryDocument)
myDiscoveryDocument.Write(stream)
End Sub
End Class