您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200509
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

实战 .Net 数据访问层 - 14

zhangxuefeng

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

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,我们就

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

 

       

 

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

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

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

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

 

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