thinkmmk
thinkmmk

Reputation: 487

Design pattern for webservice should i use

I have a requirement in my project where I will have to built a webservice. This webservice will do the following things:

  1. Accept XML format data
  2. Return XML format data
  3. The XML input data will have an element will have login information and another element data which needs processing.

Now I am looking for a design pattern where in I can make the webservice code look nice neat and clean. Because the webservice has to do plenty of things like.

  1. First Parse the xml
  2. Authenticate the request by checking username and password
  3. Create objects from the data and then save the data to database
  4. Prepare and xml which will be returned to the client.

So I have around 4 major steps which will definately make the code look ugly if I write whole thing in .asmx.cs file.

If anyone can suggest any design pattern to suit this so that the code is easy to maintain in near future.

As this module is to be integrated in my existing project hence there are some restrictions, like I cant use some 3rd party module or dll.

So I was looking for something like Single Responsibilty principle, Chain of Responsibility or Command or Decorator Patterns or anyother oop concept that fits.

I have searched but havent understood which way to start.

Thanks.

M.

Upvotes: 1

Views: 351

Answers (1)

Brannon
Brannon

Reputation: 5414

I wouldn't write any of that from scratch. Use ServiceStack or MS MVC 4 for the webservice host. Rely upon them to do the conversion from XML to/from your objects. Both of those frameworks include authentication features. Start by reading their tutorials. It sounds to me like you have no experience with ORMs or micro ORMs or the various database options. I'd read a lot of tutorials on those as well.

Upvotes: 1

Related Questions