用戶端調用第三方remoting 服務程式的n中方式,VB.NET 晚期邦定還真方便

來源:互聯網
上載者:User
程式|用戶端 寫一個簡單的Remoting 服務程式,HelloWorld:)

類函數:


Public Class SimpleObjectClass SimpleObject
Inherits System.MarshalByRefObject

Public Function HelloWorld()Function HelloWorld(ByVal message As String) As String
Return "Hello World" & message
End Function

End Class
host 程式碼
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.RemotingConfiguration
Public Class HostClass Host
Public Shared Sub Main()Sub Main()
Dim channel As New Http.HttpServerChannel(6363)
ChannelServices.RegisterChannel(channel)
RegisterWellKnownServiceType(GetType(ObjectLib.SimpleObject), "simpleobject", Runtime.Remoting.WellKnownObjectMode.SingleCall)
Console.WriteLine("started ok")
Console.ReadLine()
End Sub
End Class


下面討論幾種調用方式

1.可用戶端不支援或者沒有安裝.NET Framework 的情況。

本質上remoting 服務端和用戶端走的是Soap協議,對於簡單的方法。只要用戶端能支援Soap就可以了。微軟提供了一個soaptoolkit ,比如在vb6 中調用我的remoting 服務。
Dim o As New SoapClient30
o.MSSoapInit "http://Server:6363/simpleobject?wsdl"
MsgBox o.HelloWorld("montaque")

2. 在vb.net 中調用remoting 服務。通過bindingtomoniker

Dim o As Object = System.Runtime.InteropServices.Marshal.BindToMoniker("soap:wsdl=http://localhost:6363/simpleobject?wsdl")
MsgBox(o.helloworld("asdf")) 當然要設定option explicit off

上述代碼好像無法翻譯成C#

3。常規的方式,忽略。。。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.