ASP.NET + WCF 架构设计中的2个困惑问题,多谢!
gzl 2009-06-11 09:27:21 ASP.NET using WCF
client (http)=> asp.net(w3p) (wsHttpBinding)=> wcf(w3p)
wcf服务使用了wsHttpBinding 的 reliableSession,服务采用了presession的生命周期,因此在调用wcf服务的asp.net端,将服务的ClientBase(client proxy)和ChannelFactory都放入了HttpSessionState中,即相对每个asp.net session,wcf服务都只创建一次/个。
问题:
1. 在部署asp.net应用时,为了提高性能,将iis中将该asp.net应用的AppPool的Web garden配置为多个(w3p工作进程),同时也将该asp.net的sessionState配置成了StateServer(一般会使用inproc方式),在配置无误的情况下,发现asp.net应用中创建保存的wcf服务ClientBase(client proxy)和ChannelFactory不正常,是否这是由于wcf服务的ClientBase(client proxy)和ChannelFactory不能正确序列化存入StateServer有关系?如果想在这种场景中正确使用基于wsHttpBinding和reliableSession配置的presession生命周期的wcf服务,在asp.net和wcf两端的标准做法是什么?
2. 在上述的架构中,为了提高wcf服务的性能,在部署服务的iis中将其AppPool的Web garden配置为多个(w3p工作进程),此时发现由于每次asp.net调用wcf服务的请求不会固定在一个wcf服务的w3p工作进程上执行,造成asp.net应用session中保存的wcf服务ClientBase(client proxy)和ChannelFactory与wcf服务器端的session数据对应不上,造成随机依次报出如下异常:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
The remote endpoint no longer recognizes this sequence. This is most likely due to an abort on the remote endpoint. The value of wsrm:Identifier is not a known Sequence identifier. The reliable session was faulted.
想确认这种情况是否是会话保持不正确造成的?将asp.net应用调用服务的请求保持在固定的wcf w3p工作进程的方法是什么?