tags:

views:

30

answers:

1

Hi, im brand spanking new to WCF and Im trying to understand how to correctly expose my BLL to it. I created my first Resource.svc and IResource.svc

Resource.svc

[ServiceBehavior]
 public class Resources : IResources
    {


        #region IResources Members


        public List<Model.Resource> GetAll()
        {
            return Repository.Inventory.Resource.GetAll(true);
        }

         public List<Model.Resource> GetAllEnabled()
        {
            return Repository.Inventory.Resource.GetAllEnabled(true);
        }

        #endregion
    }

  IResource.cs
  [ServiceContract]
    public interface IResources
    {

        [OperationContract]
        List<Model.Resource> GetAll();

        [OperationContract]
        List<Model.Resource> GetAllEnabled();

    }

So this all works, My windows app can talk to the service and all is great. So I now need to access some information, I have created another .svc file called Project.svc and IProject.cs, this contains the same info as resource (apart from the type is Project) But this now means I have another webservice, surley this is not right!?

alt text

A: 

That is correct. Each new service you add to your WCF project will require its own SVC file. This can get convoluted if you expose many different services. There are solutions such as architecting your WCF services to use the REST-style and base which service gets called from the URL, so one SVC could figure out which underlying service and method to call. To do that would mean having to roll your own ServiceHost though.

arabian tiger