Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am discovering web services to implement in my ASP.Net website. I visited many sites about Why use webservices and read many articles and found out that web services are good when you have something that is used frequently without loading your page.

I want to know some other example scenarios where web services are used. Whether i can use web services in sending an order form to database or it is just for textbox box auto completion like google and etc.

Note: I know web services can be used from mobile, web or desktop applications. But My question is
When do I use web service in ASP.Net Application?

Some articles I've read so far

share|improve this question

closed as not constructive by Glenn Nelson, Kilian Foth, Rein Henrichs, Caleb, Martijn Pieters Apr 4 '13 at 17:47

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Q: "Should I use web services?" A: "Only if you want to use your data somewhere besides the system where it's produced." –  GalacticCowboy Apr 4 '13 at 14:19

2 Answers 2

Lets go back to basics:

Service: work done for somebody else: work done by somebody for somebody else as a job, duty, punishment, or favor.

As the definition implies, is there anywhere in your application where you need code to perform work for any other piece of code?

"Everywhere" you might say, that's what classes do! ... and at a fundamental level you'd be right. There's an interesting parallel that is made in Programming WCF Services between the structure of ordinary code (with metadata, an interface and an implementation) and web services that also have those properties. So essentially all code can be classified as a service. I think that's a pretty interesting and valuable insight into this class of problems.

If a class is really, functionally equivalent to a service... what questions do you ask yourself when you decide to make a new class? Keep in mind the SOLID principles here.

I posit that you will (or should) ask yourself these same questions when deciding whether or not to make a web service, but only at a higher level of abstraction.

For a class, some such questions would be*:

  • Is there a set of common functions that the rest of my code needs to consume?
  • is there a set of common data that the rest of my code will need to know/have access to?
  • Am I coding the same structure over and over in my project(s)?
  • Am I coding the same thing/pattern over and over in my project(s)?

Take these kinds of questions to a higher level of abstraction, or a larger logically related set of code, and if you answer "yes", then you have a candidate for a web service.

*not an exhaustive list

share|improve this answer

I would say that the biggest reasons to use webservices are 1) potential for decoupling and abstracting sections of functionality, and 2) to make more flexible APIs into your system.

If your site is destined to always be in just ASP.NET without worrying about integrating other technologies (maybe some AJAX here or there), then it's a toss-up. You could use webservices or not -- you don't need them.

But if you want to create a website that allows more varied functionality, or if you want to open up APIs for the world (which allows mashups, 3rd party clients, etc.) then webservices are a very good way to accomplish that. They can valuable even if just used internally.

If you do build out services, I'd suggest REST -- it seems to be gaining more steam than SOAP.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.