一个“类”中,不能多次调用“WCF 代理类”中同一方法???

starrybinding 2012-05-30 06:50:59
一个“类”中,不能多次调用“WCF 代理类”中同一方法???

代码如下:

private void BindBaseDatas()
{
string weburl = Application.Current.Host.Source.ToString();
weburl = weburl.Substring(0, (weburl.Length - 23)) + "/ChartsService.svc";
MyChartsService.ChartsServiceClient client = new MyChartsService.ChartsServiceClient("CustomBinding_ChartsService1", weburl);


client.GetCodeDetailsEntityDataAsync("BldingFunction");
client.GetCodeDetailsEntityDataCompleted+=new EventHandler<GetCodeDetailsEntityDataCompletedEventArgs>(client_GetCodeDetailsEntityDataCompleted2);



client.GetCodeDetailsEntityDataAsync("MeterUseType");
client.GetCodeDetailsEntityDataCompleted += new EventHandler<MyChartsService.GetCodeDetailsEntityDataCompletedEventArgs>(client_GetCodeDetailsEntityDataCompleted);



BindYears();
}

void client_GetCodeDetailsEntityDataCompleted2(object sender, MyChartsService.GetCodeDetailsEntityDataCompletedEventArgs e)
{
tlb_Region.ItemsSource = e.Result;
tlb_Region.SelectedIndex = 0;

//GetMonitorDatas();
}

void client_GetCodeDetailsEntityDataCompleted(object sender, MyChartsService.GetCodeDetailsEntityDataCompletedEventArgs e)
{
RadMenuItem rmi_all = new RadMenuItem();

rmi_all.Header = "总量";
rmi_all.Tag = "";
rmi_all.IsCheckable = true;
rmi_all.IsChecked = true;

rmi_Subentry.Items.Add(rmi_all);

ObservableCollection<MyChartsService.CodeDetailsEntity> subentrys = e.Result;
foreach (var st in subentrys)
{
RadMenuItem rmi = new RadMenuItem();
rmi.Header = st.DpCodeName;
rmi.Tag = st.DpCodeId;
rmi.IsCheckable = true;

rmi_Subentry.Items.Add(rmi);
}
}

问题:像这样的需求,需要多次调用“代理类”中的“同一方法"应该怎么办???这是一个WCF缺点啊。。。
...全文
95 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
starrycheng 2012-06-01
  • 打赏
  • 举报
回复
问题三:怎么实现多次调用同一个服务???


比如:需要两次调用“GetMonitoringDatasEntity”服务方法,就要再创建一个“GetMonitoringDatasEntityTwo”服务方法,它们的参数和返回值都是一样的。

这个问题可以解决吗??? Thanks a lot... 完整代码如下:


private void BindBaseDatas()
{
string weburl = Application.Current.Host.Source.ToString();
weburl = weburl.Substring(0, (weburl.Length - 23)) + "/ChartsService.svc";
MyChartsService.ChartsServiceClient client = new MyChartsService.ChartsServiceClient("CustomBinding_ChartsService1", weburl);


client.GetMonitoringDatasEntityAsync(monitortype, monitordate_type, monitordate_value, monitortype_type, monitortype_value, meterusetype, true);

client.GetMonitoringDatasEntityCompleted += new EventHandler<GetMonitoringDatasEntityCompletedEventArgs>(client_GetMonitoringDatasEntityCompleted);


client.GetMonitoringDatasEntityTwoAsync(monitortype, monitordate_type, monitordate_value, monitortype_type, monitortype_value, meterusetype, false);
client.GetMonitoringDatasEntityTwoCompleted += new EventHandler<GetMonitoringDatasEntityTwoCompletedEventArgs>(client_GetMonitoringDatasEntityTwoCompleted);


BindChart();
}
starrycheng 2012-06-01
  • 打赏
  • 举报
回复
实例化模式:WCF4.0 默认的“DataSerialize" 。 没有开启会话。。。

问题1:


如上面所示,在“BindBaseDatas()”方法中“两次”调用了“client.GetCodeDetailsEntityDataCompleted”,它们都委托给了同一个“client_GetCodeDetailsEntityDataCompleted”,这样怎么处理返回的数据???

问题二:

如上面所示,在“BindBaseDatas()”方法中“两次”调用了“client.GetCodeDetailsEntityDataCompleted”,它们分别委托给“client_GetCodeDetailsEntityDataCompleted”个“client_GetCodeDetailsEntityDataCompleted”和“client_GetCodeDetailsEntityDataCompleted2”, 但是返回只有第二次调用服务返回的数据,怎么办???

问题三:怎么实现多次调用同一个服务???
starrycheng 2012-05-30
  • 打赏
  • 举报
回复
同一个方法两次调用有点问题吭。。。

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧