Demo基于http://www.cnblogs.com/zhili/p/NETRemoting.html

RemotingObj

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Metadata;
using System.Text;
using System.Threading.Tasks; namespace RemotingServer
{
public class RemotingObject:MarshalByRefObject
{
public int TestTcpAdd(int first,int second)
{
return first + second;
} public int TestHttpMinus(int first,int second)
{
return first - second;
} [SoapMethod(XmlNamespace = "RemotingServer", SoapAction = "RemotingServer#TestMultiIpc")]
public int TestMultiIpc(int first, int second)
{
return first*second;
}
}
}

  

RemotingServer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels.Ipc;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
using System.Threading.Tasks; namespace RemotingServer
{
class Program
{
static void Main(string[] args)
{
TcpChannel tcpChannel = new TcpChannel(2046);
HttpChannel httpChannel = new HttpChannel(9001);
IpcChannel ipcChannel = new IpcChannel("IpcTest"); ChannelServices.RegisterChannel(tcpChannel,false);
ChannelServices.RegisterChannel(httpChannel,false);
ChannelServices.RegisterChannel(ipcChannel,false); Console.WriteLine("The name of the Tcp Channel:{0}",tcpChannel.ChannelName);
Console.WriteLine("The priority of the Tcp Channel:{0}",tcpChannel.ChannelPriority); Console.WriteLine("The name of the Http Channel:{0}",httpChannel.ChannelName);
Console.WriteLine("The priority of the Http Channel:{0}",httpChannel.ChannelPriority); Console.WriteLine("The name of IPC Channel :{0}",ipcChannel.ChannelName);
Console.WriteLine("The priority of Ipc Channel:{0}",ipcChannel.ChannelPriority); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingServer.RemotingObject), "RemotingObject",WellKnownObjectMode.Singleton);
Console.ReadKey();
}
}
}

  

RemotingClinet

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RemotingServer; namespace RemotingClient
{
class Program
{
static void Main(string[] args)
{
RemotingObject proxyTcp =
Activator.GetObject(typeof (RemotingObject), "tcp://localhost:2046/RemotingObject") as RemotingObject;
if (proxyTcp == null)
{
Console.WriteLine("连接Tcp服务失败!");
return; } RemotingObject proxyHttp =
Activator.GetObject(typeof(RemotingObject), "http://localhost:9001/RemotingObject") as RemotingObject;
if (proxyHttp==null)
{
Console.WriteLine("连接Http服务失败!");
return;
} RemotingObject proxyIpc =
Activator.GetObject(typeof(RemotingObject), "ipc://IpcTest/RemotingObject") as RemotingObject;
if (proxyIpc == null)
{
Console.WriteLine("连接IPC失败!");
return;
} // 输出信息
Console.WriteLine("This call object by TcpChannel, 100 + 200 = {0}", proxyTcp.TestTcpAdd(100, 200));
Console.WriteLine("This call object by HttpChannel, 100 - 200 = {0}", proxyHttp.TestHttpMinus(100, 200));
Console.WriteLine("This call object by IpcChannel, 100 * 200 = {0}", proxyIpc.TestMultiIpc(100, 200));
Console.WriteLine("Press any key to exit!");
Console.ReadLine();
}
}
}

  

备注:

Remoting在HttpChannel下抛“指定的 SOAPAction 无效

解决方法:

1:将Server和Client所在的程序集修改成相同的程序集名。

http://blog.csdn.net/lilin8905/article/details/6232640

2:在需要使用httpChannel的方法上面加上SoapMethod标签

[SoapMethod(XmlNamespace = "命名空间", SoapAction = "命名空间#方法名")]

http://blog.csdn.net/sloder/article/details/8694560

Xmind

练习代码

Remote小Demo的更多相关文章

  1. 新手 gulp+ seajs 小demo

    首先,不说废话,它的介绍和作者就不在多说了,网上一百度一大堆: 我在这里只是来写写我这2天抽空对seajs的了解并爬过的坑,和实现的一个小demo(纯属为了实现,高手请绕道); 一.环境工具及安装 1 ...

  2. Nancy之基于Nancy.Hosting.Self的小Demo

    继昨天的Nancy之基于Nancy.Hosting.Aspnet的小Demo后, 今天来做个基于Nancy.Hosting.Self的小Demo. 关于Self Hosting Nancy,官方文档的 ...

  3. Nancy之基于Nancy.Owin的小Demo

    前面做了基于Nancy.Hosting.Aspnet和Nancy.Hosting.Self的小Demo 今天我们来做个基于Nancy.Owin的小Demo 开始之前我们来说说什么是Owin和Katan ...

  4. Nancy之基于Self Hosting的补充小Demo

    前面把Hosting Nancy with ASP.NET.Self Hosting Nancy和Hosting Nancy with OWIN 以demo的形式简单描述了一下. 这篇是为Self H ...

  5. [Unity3D]做个小Demo学习Input.touches

    [Unity3D]做个小Demo学习Input.touches 学不如做,下面用一个简单的Demo展示的Input.touches各项字段,有图有真相. 本项目已发布到Github,地址在(https ...

  6. Android -- 自定义View小Demo,动态画圆(一)

    1,转载:(http://blog.csdn.NET/lmj623565791/article/details/24500107),现在如下图的效果: 由上面的效果图可以看到其实是一个在一个圆上换不同 ...

  7. Win10 FaceAPI小demo开发问题汇总

    Win10 FaceAPI小demo开发问题汇总 最近使用微软牛津计划做一个小demo,使用FaceAPI做一个小应用,实现刷脸的功能.开发的过程中用到几个问题,具体如下: Stream 与IRand ...

  8. 模仿京东顶部搜索条效果制作的一个小demo

    最近模仿京东顶部搜索条效果制作的一个小demo,特贴到这里,今后如果有用到可以参考一下,代码如下 #define kScreenWidth [UIScreen mainScreen].bounds.s ...

  9. Android学习小Demo一个显示行线的自定义EditText

    今天在处理一个EditText的时候,想着把EditText做成像一本作业本上的纸一样,每一行都可以由线条隔开,具体效果如下: 1)最开始的思路 一开始的想法是很简单的,找出每一行的高度,然后一行一行 ...

随机推荐

  1. 一步步学习Python-django开发-添加后台管理

    Pyhon-djano提供了一个很强大的后台管理功能,你很轻松的就可以拥有一个后台管理平台.你需要做啥呢?你只需要将需要管理员进行管理的表注册到管理site中即可: from django.contr ...

  2. Java静态代理和动态代理

    今天介绍一下代理设计模式,在业务场景中使用代理模式的好处有很多,包括什么权限校验,事务管理等等,具体有什么好处大家自动百度吧,我这里只解释代理模式的设计原理.首先这个设计模式出来的时候先是静态代理模式 ...

  3. Arduino 各种模块篇 motor shield

    根据arduino官方网站出的shield, 类似的情况有很多中motor shield 这里测试采用的是http://www.seeedstudio.com/wiki/Motor_Shield_V1 ...

  4. Java线程同步之一--AQS

    Java线程同步之一--AQS 线程同步是指两个并发执行的线程在同一时间不同时执行某一部分的程序.同步问题在生活中也很常见,就比如在麦当劳点餐,假设只有一个服务员能够提供点餐服务.每个服务员在同一时刻 ...

  5. hive 不同用户 权限设置 出错处理

    今天安装了hive 在a账号安装的,一切正常 但是到其他账户下,报错 >show tables; Error in metadata: java.lang.RuntimeException: U ...

  6. log4net 开箱即用

    废话少说,先上代码 log4net Demo 好的系统都有日志,log4net 是我在.net平台下用过最爽的日志库,简单易用.功能强大. 基于配置(配置很简单,一看就明,通用,拷去即用): 可同时保 ...

  7. Netty轻量级对象池实现分析

    什么是对象池技术?对象池应用在哪些地方? 对象池其实就是缓存一些对象从而避免大量创建同一个类型的对象,类似线程池的概念.对象池缓存了一些已经创建好的对象,避免需要时才创建对象,同时限制了实例的个数.池 ...

  8. 分别使用Hadoop和Spark实现二次排序

    零.序(注意本部分与标题无太大关系,可直接调至第一部分) 既然没用为啥会有序?原因不想再开一篇文章,来抒发点什么感想或者计划了,就在这里写点好了: 前些日子买了几本书,打算学习和研究大数据方面的知识, ...

  9. 二、mongo数据库

    官网:https://www.mongodb.com/ 进入官网 右上角有个下载按钮Download 1.完成安装后:运行--cmd(命令面板) 2.常用命令: 打开数据库 mongod –dbpat ...

  10. hdu1040

    #include<stdio.h>#include<stdlib.h>int a[100];int cmp(const void *a,const void *b){ retu ...