Remoting服务集成到IIS的简单总结

    因为项目的Remoting服务有可能集成到IIS中,所以下午利用一些时间,做了一个例子,实现了需要的功能,代码就凑合一下。
现在把这个过程总结一下:

1.       创建远程对象类Class1,它实现一个接口Interface1

public class Class1 : MarshalByRefObject, Interface1
    {
        #region Interface1 Members
        public string SendMessage(string msg)
        {
            return "Hello " + msg;
        }
        #endregion
       public override object InitializeLifetimeService()
        {
            return null;
        }
    }

    public interface Interface1
   {
        string SendMessage(string msg);
    }

2.      建立虚拟目录



根据自己的需要选择选项,我是偷懒,不想受什么限制。生活中已经受到很多限制,难道在自己的机器上做开发还要收到限制吗?

F:\IISTest目录下建立Bin目录,然后将包含远程对象类的组件IISClassLibrary1.dll放入bin目录中。并创建Web.config

<system.runtime.remoting>
    <application>
      <service>
        <wellknownmode="Singleton"
                   type="IISClassLibrary1.Class1,IISClassLibrary1"
                   objectUri="Class1.soap"/>
      </service>
     <channels>
        <channel
           name="MyChannel"
           priority="100"
           ref="http"
            />
      </channels>
    </application>
 </system.runtime.remoting>

3.      建立客户端

使用配置文件,创建App.config配置文件

<?
xmlversion="1.0"encoding="utf-8" ?>
<configuration>
 <system.runtime.remoting>
    <application>
     <client>
       <wellknowntype="IISClassLibrary1.Class1,IISClassLibrary1"
                   url="http://localhost/IISTest/Class1.soap"/>

      </client>
    </application>
 </system.runtime.remoting>
</configuration>


            //客户端调用
            string
filename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            RemotingConfiguration.Configure(filename,false);

            IISClassLibrary1.Interface1 mgr = new IISClassLibrary1.Class1();           

            string retValue = mgr.SendMessage("yiping");

            获得所需要的结果:Hello yiping

    用“Hello yiping"给自己打气,努力做到“不抛弃,不放弃”,希望生活一天比一天美好。

           

转载于:https://www.cnblogs.com/yiping06993010/archive/2007/08/27/871469.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值