English 中文(简体)
Should we create local web services within an Asp.Net application which are called by the application itself?
原标题:

I ve moved to a new project team and while going over the codebase, found that the team have created a number of local web services which then get called by server code in other web pages within the same application.

I m somewhat puzzled by this architecture, as I d thought local web services were something you d then access from the client, or from other distinct applications.

However by communicating with the local web service from other server code in our application, it seems to me that we re going through the rigmarole of wrapping the message into XML/Soap and thru the html stack to the service and then back again and will end up adding a shedful of time and slow down the application.

Have mentioned my concerns on this to my new colleagues, and theres been a bit of debate. Just wondered what others thought of this approach and am I right to be concerned?

Thanks

Mickey

最佳回答

I think you are right to be a bit surprised that the team would implement a web service call within the application - why pay the overhead?

The real problem, though, isn t necessarily the web service call - this is a legitimate technique. The greater problem is likely to be in your division of responsibilities. The web service handler is akin to the UI in a standard page: there to handle the interaction with the outside world. It should be passing off the arguments it receives to a business logic object.

The advantages of a separate business logic object are manifold: easier unit testing and the ability to call directly into the same function from within your code are the most prominent. Thus, they should probably refactor the logic out of the web service and into a business logic object and call the object directly rather than incurring the overhead of the web service call.

问题回答

Using local web services is not a bad thing. It can increase the modularization (increased cohesion, decreased coupling) of a given application. Moving the target code into a web service can be thought of like creating a shared library (DLL, .so, etc.) with the important benefit of being easily called from different processes. It s like getting RPC or DCOM for much less headache. As long as you keep the calling convention clear, it shouldn t be a problem to create applications that are almost entirely made up of web service calls. It s the application version of Mash-ups.

Even though yoru web service gets called by 1 client at the moment, perhaps there will be other clients in the future. From that point of view I d be more concerned about whether the application partition makes sense architecturally. That is, is that a good separation of concerns? Of course performance is another consideration.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签