Doubt in the construction of WS REST(Contract)

Asked

Viewed 106 times

-1

Gentlemen, I took an example in the book of john Sharp(microsoft press) to build a REST and came a simple doubt, but a doubt of good practices.

He uses the Northwind BD. He creates a Class Library project and points that project to the Products entity. The question is:

I must create for each entity of my WS a new Class Library project or I can make use of the same Multi-entity Project?

P.S. In my WS I will use 5 BD Entities(PDV,Establishment,User,User and Locality(This in another Context)).

One question: When I have a URI in this format in my Interface:

[OperationContract]
[WebGet(UriTemplate = "/")]

Does it mean that it is a URL without parameters? That is, I can have a URI like this and a method with parameter like this:

[ServiceContract]
    public interface ISuporteContract
    {
        [OperationContract]
        [WebGet(UriTemplate = "/")]
        public List<string> getCnpjParceiro(string _cnpj);
    }
  • 1

    I think you can create a model folder and create a . Cs for each entity that is already separated.

  • You create a Class Library to put these entities (all) and their context. Then refer to the same your final project.

  • Just for the sake of good practice. A web service REST has almost three distinct steps. Interfaces, Contracts and the SVC itself. These folders can be in the same Solution, right? In my main project, the Model folder I only have my EDMX. Mine. Cs are in the Entities folder. I see this only as a form of organization. I had created another Class Library project to start developing my WS. If I’m going to follow your lead, I should create a printer and put the WS classes in there, okay? Another Interface Printer and SVC will be another project within sln, ok?

  • 1

    @pnet, is a lot of information, I believe you should post all these questions in the main question. I do each project separately and if I need to use the references. Example if I do Web place a Library class for the Entity with the classes Repository, if I create a Ws create another project in the same Solution and if I need to use the Entity I do reference. Before I study what I will do and the best form of organization. The rule I use is in relation to POO, responsibilities, low coupling, improvement layers etc ...

  • 1

    Exactly what I’m doing, a study of everything before I start. I haven’t started developing yet. I need more grant. I confess that it is a lot of information yes. I will dismember to become more cohesive(High Cohesion and Low coupling, eheh)

1 answer

1


The Entities classes you can keep in a single Class Library project (Example: Meuapp.Dominio). Optionally in this same project you can maintain the interfaces (Contracts) of your services, however . Svcs must be in another project (Web, Console, etc.) to enable a better reuse of domain classes and avoid a strong linkage (dependency/reference) between the web exposure of services and your business logic.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.