Muru
Muru

Reputation: 51

ASP.NET web service architecture/structure

I am going to create a new asp.net web service (.NET framework 2.0), the functionality of the web service is to recieve xml input, perform the relevant operation (add/modify/delete) based on the input and return codes which indicates the status of the operation. I am planning to implement two layer architecture (Business layer and database layer) for this web service, could anyone advise whether this is the right structure or any other structure would perform well than this. Basically I need some inputs on designing the web service.

Thanks in advance.

Thanks, Muru

Upvotes: 5

Views: 1924

Answers (3)

Michel
Michel

Reputation: 23645

i always use the same model: service / business layer and a database layer. When it comes to Visual studio, i have 4 or 5 projects:

1 with the webservice named project.webservice (which ONLY task it is to receive input and give that input to the layer that does the thinking (business layer), so testing is easyly done to the business layer

1 with the service layer named project.service which does the actual work (decide what the operation should be, call the right db methods etc)

1 with the database logic called project.datalayer which could be ADO.Net code or the Entity framework.

1 with the dataclasses called project.model. These classes are the ones returned by the ADO.Net code and used by the service and the webservice project. If i use a entity framework i normally skip this project, because the EF itself gives me dataclasses the EF generates. Sometimes clients don't want to use the EF dataclasses, then i create the project.model project and let the datalayer translate the EF dataclasses to project.model dataclasses

1 with the testproject named project.test

hop this helps,

Michel

Upvotes: 0

user338195
user338195

Reputation:

I would write a web service using ASMX because it's easier to get your head around to start with.

Implement DAL by using ADO or LINQ (might be easier option since it does all the mapping for you and it's good to learn something new imo).

How are you going to call a web service? Did you consider how you will return status code? You can look into JavaScript and Ajax so that you can return custom objects to the client, or you could look into SOAP, which is xml based.

Can also recommend a good read - ASP.Net and Ajax: architecting web applications. Might give you a better idea on what options you have.

Upvotes: 0

Mark Seemann
Mark Seemann

Reputation: 233347

The Domain Model should express the business logic in a way that is independent on boundary technologies such as WCF or ASP.NET web services.

This adds the requirement of a third layer:

  • Service
  • Domain Model
  • Data access

If you don't make a separate layer for the technology specific interfaces (Service), you might as well just make a single, monolithic application, because you wouldn't be able to reuse the business logic anyway.

While we're at it: use WCF, not ASMX, for web services.

Upvotes: 3

Related Questions