简体   繁体   English

用单一方法异步化Web服务响应是否存在任何潜在问题?

[英]Are there any potential problems with having a single method to async webservice responses?

I have a Silverlight client application that communicated with a WCF web service for all sorts of things. 我有一个Silverlight客户端应用程序,它与WCF Web服务进行了各种通讯。 All of the returns from these web services are inherited from a base ResponseObject. 这些Web服务的所有返回值都继承自基本ResponseObject。 I have several methods to handle the async calls, one for each method call, with the appropriate handler added. 我有几种方法来处理异步调用,每个方法调用一个,并添加适当的处理程序。 I'm thinking now, wouldn't it be easier just to have a single method for all responses, and then have a switch statement that casts my response object accordingly. 我现在在想,只为所有响应提供一个方法,然后有一个switch语句相应地转换我的响应对象,这会不会容易得多。 I generally don't have big methods to handle returns, just things like populating a combobox, etc. 我通常没有大的方法来处理退货,例如填充组合框之类的东西。

Is there a reason why doing it this way would be bad? 有这种理由这样做不好的理由吗? I send around so many small data requests, sometimes it seems like I spend half my time writing those response methods, even if they are trivial to do so. 我发送了许多小数据请求,有时似乎我花了一半的时间编写这些响应方法,即使这样做很琐碎。

Could you write a T4 template that generates these methods for you? 您可以编写一个T4模板为您生成这些方法吗? You could read in the WSDL of the web service to see what methods need to be generated. 您可以阅读Web服务的WSDL,以查看需要生成哪些方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM