日期:2012-04-06  浏览次数:20628 次

代码12:使用Data Access Logic进行Remoting调用 – 2,Remoting访问

class CustomerDal_ORM : MyDal

{

// 请注意:这个delegate方法被限制为private访问权限

private ArrayList GetAllCustomers_Remoting_delegate()

{

ArrayList al = null;



RemoteCustomer remote = (RemoteCustomer)Activator.GetObject(

typeof(RemotingClass.RemoteCustomer),

Helper.GetApplicationSetting("RemotingUrl"));



if (remote == null)

throw new Exception("Could not locate server!");

else

{

al = remote.GetAllCustomers();

}



return al;

}

}





















































上面的两段代码应该不难理解,如果结合前面的DAF,我们就

可以画出这样一张调用示意图:







以上代码11,12(上图中的1~6步骤)仅仅是客户端行为,而

在服务器端,我们还不得不做这么两件事情:

(1) 建立一个Host程序(如果使用Http+Soap来模拟WebServies,由于该种Remoting行为可直接Host在ASP.NET下,故可省去本步骤),主要用于在指定端口注册服务(曾听朋友说起,网上也有人写过Remoting Host Manager,感兴趣的同志可以去CodeProject查查J);

(2) 建立一个继承自MarshalByRefObject的服务类,该类将被步骤1中的Host程序用于注册操作;



下一段:http://www.csdn.net/develop/Read_Article.asp?id=27558