服务端 Remoting 配置:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref=”http” port=”8086″/>
</channels>
<service>
<wellknown mode=”Singleton”
type=”ClassLibrary.Calculate,ClassLibrary”
objectUri=”Calculate” />
</service>
</application>
</system.runtime.remoting>
</configuration>
服务端代码:
RemotingConfiguration.Configure(“Server.exe.config”, false);
Console.WriteLine(“HTTP通道建立,名称:{0}”, ChannelServices.RegisteredChannels.First().ChannelName);
运行服务端,服务端创建通道成功,IE中输入http://localhost:8086/Calculate?wsdl 能查看到对应的wsdl
客户端 Remoting 配置:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknow type=”ClassLibrary.Calculate,ClassLibrary”
url=”http://localhost:8086/Calculate”/>
</client>
<channels>
<channel ref=”http” port=”0″/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
客户端代码:
RemotingConfiguration.Configure(“Client.exe.config”, false);
Calculate obj = new Calculate();
但这里生成的obj并不是一个proxy,我很奇怪,配置文件没有问题呀,如下图:
我换种写法,客户端不用配置文件,如下:
RemotingConfiguration.RegisterWellKnownClientType(typeof(Calculate), “http://localhost:8086/Calculate”);
Calculate obj = new Calculate();
这样的写法又是正常的,如下:
这是为什么呀?客户端的配置文件我真看不出来哪里有问题,就这么几行东西,谁给解答一下呀