當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET NetMsmqBinding類代碼示例

本文整理匯總了VB.NET中System.ServiceModel.NetMsmqBinding的典型用法代碼示例。如果您正苦於以下問題:VB.NET NetMsmqBinding類的具體用法?VB.NET NetMsmqBinding怎麽用?VB.NET NetMsmqBinding使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了NetMsmqBinding類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: Add

' Define a service contract. 
<ServiceContract(Namespace:="http://Microsoft.ServiceModel.Samples")> _
Public Interface IQueueCalculator
    <OperationContract(IsOneWay:=True)> _
    Sub Add(ByVal n1 As Double, ByVal n2 As Double)
    <OperationContract(IsOneWay := True)> _
    Sub Subtract(ByVal n1 As Double, ByVal n2 As Double)
    <OperationContract(IsOneWay := True)> _
    Sub Multiply(ByVal n1 As Double, ByVal n2 As Double)
    <OperationContract(IsOneWay := True)> _
    Sub Divide(ByVal n1 As Double, ByVal n2 As Double)
End Interface
開發者ID:VB.NET開發者,項目名稱:System.ServiceModel,代碼行數:12,代碼來源:NetMsmqBinding

示例2: Add

' Service class that implements the service contract.
' Added code to write output to the console window
Public Class CalculatorService
    Implements IQueueCalculator
    <OperationBehavior> _
    Public Sub Add(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Add
        Dim result As Double = n1 + n2
        Console.WriteLine("Received Add({0},{1}) - result: {2}", n1, n2, result)
    End Sub

    <OperationBehavior> _
    Public Sub Subtract(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Subtract
        Dim result As Double = n1 - n2
        Console.WriteLine("Received Subtract({0},{1}) - result: {2}", n1, n2, result)
    End Sub

    <OperationBehavior> _
    Public Sub Multiply(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Multiply
        Dim result As Double = n1 * n2
        Console.WriteLine("Received Multiply({0},{1}) - result: {2}", n1, n2, result)
    End Sub

    <OperationBehavior> _
    Public Sub Divide(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Divide
        Dim result As Double = n1 / n2
        Console.WriteLine("Received Divide({0},{1}) - result: {2}", n1, n2, result)
    End Sub
End Class
開發者ID:VB.NET開發者,項目名稱:System.ServiceModel,代碼行數:28,代碼來源:NetMsmqBinding

示例3: Main

' This is the hosting application. This code can appear directly in the service class as well.
Friend Class HostApp
    ' Host the service within this EXE console application.
    Public Shared Sub Main()
        ' Get MSMQ queue name from appsettings in configuration.
        Dim queueName As String = ConfigurationManager.AppSettings("queueName")

        ' Create the transacted MSMQ queue if necessary.
        If (Not MessageQueue.Exists(queueName)) Then
            MessageQueue.Create(queueName, True)
        End If

        ' Get the base address that is used to listen for WS-MetaDataExchange requests.
        ' This is useful to generate a proxy for the client.
        Dim baseAddress As String = ConfigurationManager.AppSettings("baseAddress")

        ' Create a ServiceHost for the CalculatorService type.
        Using serviceHost As New ServiceHost(GetType(CalculatorService), New Uri(baseAddress))
            ' Open the ServiceHostBase to create listeners and start listening for messages.
            serviceHost.Open()

            ' The service can now be accessed.
            Console.WriteLine("The service is ready.")
            Console.WriteLine("Press <ENTER> to terminate service.")
            Console.WriteLine()
            Console.ReadLine()

            ' Close the ServiceHostBase to shutdown the service.
            serviceHost.Close()
        End Using
    End Sub
End Class
開發者ID:VB.NET開發者,項目名稱:System.ServiceModel,代碼行數:32,代碼來源:NetMsmqBinding


注:本文中的System.ServiceModel.NetMsmqBinding類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。