Some questions confusing me guys, I'm just new to web services altogether.
What is the difference between web service, web methods and server side code ?
Where is web service preferred over server side methods?
Where are web methods preferred to be used ?
How does web service differ from server side post back ?
Are web services light weight ? Can they be used to save long web forms as well ?
- I开发者_Python百科n an enterprise web application, which one of these should I use frequently and why?
What is the difference between web service, web methods and server side code ?
A web service is an exposed end point that is normally used as an API, or in other words its end user is typically another application rather than a user interface. A web method is a particular method that is exposed over a web service.
On the other hand, server-side code applies to any ASP.NET web page, web service, or other technology for general implementation of its functionality.
Where is web service preferred over server side methods?
Web services excel at making an application compatible with other programming platforms or for serving up AJAX requests to a web page. There are many other uses, but typically using WCF or HttpHandlers are better options in those cases.
Where are web methods preferred to be used ?
Web methods can be used in any .aspx page or more typically in a .asmx (web service) file.
How does web service differ from server side post back ?
A server-side postback occurs when a web page posts data to the server for processing. A web service is completely different - it is an endpoint that is exposed for consumption by another application (or within the same application).
Are web services light weight ? Can they be used to save long web forms as well ?
No, web services are not light weight, in fact they are quite the opposite because they generally receive and respond to data using XML (a bulky format). However, this makes them very easy to use with other programming languages.
In an enterprise web application, which one of these should I use frequently and why?
This is a highly subjective question. Each technology in the .NET framework has a set of features that it excels at and can usually do several other things (but not very well). Each tool has its place, it is just a matter of matching the tools to use with the requirements of your project.
However, judging by the rest of your questioning, it sounds like you are just putting together a typical website that doesn't require an API, in which case it would be best to use .aspx pages and code behind.
The term "web method" has several meanings, among them:
- In the legacy ASMX web service technology, web service operations were created by adding the
[WebService]
attribute to a public class, and the[WebMethod]
attribute to public instance methods of such a class. these methods would then be exposed as web service operations. - There is a related technology, "Page Methods" that is part of ASP.NET. It basically allows you to create tiny web services by using the
[WebMethod]
attribute on a public static method of a page class.
In both cases the term is specific to the implementation technology. The generic term is "web service operation". For example, in WCF, a web service operation is created by placing the [OperationContract]
attribute on a method.
Note that ASMX is now considered by Microsoft to be a "legacy technology". All new development should use WCF.
My taxonomy:
Service - a named piece of functionality the provides some value to another component, delimited by a contract of some description.
Operation - a specifically named piece functionality that a service exposes. Generally services can expose 1 or more operations.
Web service - A Service that is exposed using web technology such as HTTP or over the internet.
Server Side Code - the implementation of the service's functionality. You can consider this to be the code that the service is made from.
Web Method - A particular term referring to an operation on a web service. In some technologies this is also use to describe the technology used to implement an operation. You use these to implement an operation - e.g. the server side code of the operation.
A server side postback is when a service calls back to the original consumer of the service usually asynchronously.
Since web services are just services exposed over internet technology they can be as heavy or light weight as needed. It depends on the requirements of the operations' contracts.
Which one should you use? Can't say each requirement is different.
The term "method" or "web method" is strictly a Microsoft terminology. It is not a proper term ever suggested by w3c standard.
Microsoft is known for bastardizing proper software terminology, including the concept of basic Object Oriented programming paradigm.
精彩评论