views:

29

answers:

1

When building a WCF service for a large scale application, which is better:

In both cases, assume that the business logic layer is separated into a different assembly.


Using your business logic layer as a service implementation i.e. with no code behind and no wrapper

<%@ ServiceHost Language="CS" Service="MyApp.BusinessLogic.BusLogicImpl" %>

or

Using the codebehind of the WCF service that wraps calls into your business logic layer.

<%@ ServiceHost Language="CS" Service="MyApp.WebServiceHost.Service" CodeBehind="Service.svc.cs" %>
A: 

If you need to have code behind your service, I would also put that into a separate assembly and store it in the .\bin directory of your ASP.NET website hosting the SVC file - I would never put that directly into a MyService.svc.cs code-behind file.

So you would have something like:

<%@ ServiceHost Language="CS" Service="MyApp.ServiceLayer.MyService" %>

and put all the logic and wrapper code you need (to call your business layer) into that assembly.

marc_s
So, the other part of the question is: do you think the wrapper should exist?
Matt Ruwe
@Matt Ruwe: yes, I think it can be quite useful, to handle things like catching a bunch of exceptions that can happen (network down etc.) and re-creating the client side proxy class if the communications channel is faulted etc.
marc_s