views:

78

answers:

3

I am looking to see what the consensus is for best practices or just plain sanity in writing apps.

For this example I have the following:

  • [HttpHandler]
  • ClientRender.ProcessRequest(…)
  • ClientFactory.GetInnerInfo(…)
  • Services.ServiceConnect.GetCampaignService(…)
  • [Web Service]
  • Campaign.GetInnerClient(…)
  • [Web Service]
  • DAL.GetInnerClient(…)
  • EnterpriseLibrary.CreateDatabase(…)
  • EnterpriseLibrary.GetStroedProcCommand(…)
  • EnterpriseLibrary.ExecuteReader(…)
  • DAL.PopulateClientCampaignFromReader(…)
  • DAL.ClientCampaignFromDataReader(…)
  • Return up the call tree…

Questions:

  1. What type of performance hits am I incurring by calling a Web Service from within a Web Service from within a HttpHandler?
  2. Would it not make more sense to rewrite this as an assembly rather than 2 Web Services? (And put the Web Services on top of the assembly for a WSDL publication.)
  3. We also have an admin website that leverages these same assemblies and it takes 2-3 days to “correctly” add a simple CRUD operation on one data entity. Would you argue for moving towards a more direct approach?

Hope this makes sense and feedback is welcome.

A: 

It's certainly the case that any valid reason for nesting the web service calls is not apparent.

That doesn't mean there is no reason, only that it's not apparent. You should probably ask those who wrote the service.

John Saunders
The only reason I have gotten so far is to allow a public API to eventually be built.
Keith Barrows
+1  A: 

IMHO that's a misunderstanding of what a Web Service should provide. Using a WS to create handle database calls makes no sense. You could:

  1. Build separate assemblies for database abstractions and business logic. Methods and classes like "GetStoredProcCommand" should belong to a single assembly, and the business logic should belong to another assembly, or group of assemblies.
  2. Use these assemblies as a basis for your WebServices.
  3. Before building the WebService, it's imperative to sit down and know who is going to use it, and how. It makes no sense to build a bunch of WebServices if you don't know what it's supposed to do. It will end up being a mess because you'll shove the real functionalities after you built it.
  4. If your webservices are supposed to be consumed from internal application, remember that there's a performance impact on using webservices. If you try to do everything via WS, it's going to be slow.
João Marcus
This is the answer I had in mind but is it *the* answer? :)
Keith Barrows
To me, this seems to be *the* answer. A public API, for example, requires consistency, something you won't have with the current design. You will end up with lots, lots of leaky abstractions.
João Marcus
It doesn't make sense for a web service to "handle database calls", but it can make sense to have an internal web service (not exposed to the public) which handles data at the "entity" level. This way, a common set of business entities can be exposed to any internal piece of software that needs it, including to other web services. ADO.NET Data Services it one attempt at a packaged implementation of this.
John Saunders
So, we have gone the direction of dropping all Web Services and we will create real ones later down the schedule. We have most of the app working in a standard DLLs + Web Site configuration now.
Keith Barrows