服务器端:
namespace RemoteServer
{
public class Scoop : MarshalByRefObject
{
public Scoop()
{
}
public string GetTheScoop(string name)
{
return "Here 's the scoop, "
+ Thread.CurrentPrincipal.Identity.Name + "! ";
}
}
}
配制文件:
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode= "SingleCall "
type= "RemoteServer.Scoop,RemoteServer "
objectUri= "Scoop.soap " />
</service>
</application>
</system.runtime.remoting>
<system.web>
<authentication mode= "None " />
<authorization>
<deny users= "? " />
</authorization>
</system.web> </configuration>
客户端:
static void Main(string[] args)
{
ChannelServices.RegisterChannel(new HttpClientChannel());
RemotingConfiguration.RegisterWellKnownClientType(
typeof(RemoteServer.Scoop),
"http://localhost/ScoopRemoting/Scoop.soap ");
Scoop srv = new Scoop();
IDictionary props = ChannelServices.GetChannelSinkProperties(srv);
props[ "username "] = "test ";
props[ "password "] = "test ";
string s = srv.GetTheScoop( "Greg ");
Console.WriteLine(s);
}
如果这样做的话,别人写个客户端不是可以随便模仿一下登录?
如果限制角色:
<authorization>
<allow role= "aaaa " />
<deny users= "* " />
</authorization>
别人如果知道你的角色是什么, 也可以写个客户端模仿吧?