The client calls the N-way of the third party Remoting service program, and VB.NET is very convenient.

xiaoxiao2021-03-06  73

Write a simple Remoting service program, HelloWorld :) class function:

Public

Class SIMPLEOBJECT

Class SimpleObject Inherits System.MarshalByrefObject Public Function HelloWorld () Function HelloWorld (Byval Message As String) AS String Return "Hello World" & Message End Functionend Class

Host program code

Imports

System.Runtime.Remoting.Channels

Imports

System.Runtime.Remoting.RemotingConfiguration

Public

Class Host

Class 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 Subend Class

Let's discuss several modes

1. The client does not support or not install .NET Framework.

Essentially Remoting server and clients walk the SOAP protocol, for simple methods. As long as the client supports SOAP. Microsoft provides a SOAPTOOLKIT, such as calling my Remoting service in VB6.

DIM

o

AS

New

SOAPCLIENT30O.MSSOAPINIT

"

HTTP: / / SERVER: 6363 / SIMPLEOBJECT? WSDL "

Msgbox

O.helloworld

"

MONTAQUE

"

)

2. Call the Remoting service in VB.NET. By bindingtomoniker

DIM

o

AS

Object

=

System.Runtime.InteropServices.Marshal.Bindtomoniker

"

SOAP: WSDL = HTTP: / / LOCALHOST: 6363 / SimpleObject? WSDL

"

)

Msgbox

(O.helloworld

"

ASDF

"

))

Of course to set OPTION Explicit Off

The above code seems to be unable to translate into C #

3. Conventional way, ignore. . .

转载请注明原文地址:https://www.9cbs.com/read-92720.html

New Post(0)