.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
客户端调用第三方remoting 服务程序的n中方式,VB.NET 晚期邦定还真方便

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

写一个简单的Remoting 服务程序,HelloWorld:)

类函数:

Public Class SimpleObject
    
Inherits System.MarshalByRefObject

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


End Class

host 程序代码
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.RemotingConfiguration
Public Class Host
    
Public Shared 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。常规的方式,忽略。。。
 


相关文章

相关软件