2小零件对这个问题哪希望能澄清一些模糊的我。WCF呼叫 - 最佳实践
首先,这是调用WCF服务的更好吗?
using (var myService = new ServiceClient("httpBinding")){
try{
var customerDetails = GetCustomerDetails();
var results = myService.GetCustomerPurchases(customerDetails);
}catch(Exception e){
......
}
}
或
var myService = new ServiceClient("httpBinding");
try{
var customerDetails = GetCustomerDetails();
var results = myService.GetCustomerPurchases(customerDetails);
}catch(Exception e){
.......
}
我想知道是,我就应该总是缠绕我的服务呼叫在使用块?是否IDisposable.Dispose()获取如果服务抛出一个异常,叫什么名字?
非常感谢,非常有帮助 - 欣赏花在那里的时间 – Chris
这真的很酷..但如何为此编写单元测试用例。任何其他可以模拟服务参考的方法? – Prashant