-1

I created web service in visual studio 2010 three years back. I use this Web service in my winform project for performing some online functions. Now I want to create web service in visual studio 2013. Here I see web api instead of traditional web service. So my question is that what is the difference between traditional web service and Web api? And can I achieve the same thing in web api which I do in traditional web service?

user3004110
  • 929
  • 10
  • 24
  • 36
  • What is a Traditional Web Service for you? a WCF Web Service? – Leandro Bardelli Nov 14 '14 at 16:58
  • I mean when we create new project and choose web service in visual studio 2010. This option is missing in visual studio 2013. – user3004110 Nov 14 '14 at 17:05
  • There is no such opcion as web service, I think you are talking about wcf – Leandro Bardelli Nov 14 '14 at 17:18
  • possible duplicate of [WCF vs ASP.NET Web API](http://stackoverflow.com/questions/9348639/wcf-vs-asp-net-web-api) – Leandro Bardelli Nov 14 '14 at 17:18
  • I am sorry if i didn't told you clearly. I am creating asp.net web service (is it WCF web service?) in visual studio 2008 and then calling/connecting this web service in my win form application. For reference this web service see this URL: http://www.c-sharpcorner.com/UploadFile/4d9083/create-simple-web-service-in-visual-studio-2008-2010-2012/. Please tell me that this type of web service can be developed in web API? because i cannot see web service option in visual studio 2013, thanks. – user3004110 Nov 14 '14 at 17:34

1 Answers1

3

Web Service in ASP.NET

A Web Service is programmable application logic accessible via standard Web protocols. One of these Web protocols is the Simple Object Access Protocol (SOAP). SOAP is a W3C submitted note (as of May 2000) that uses standards based technologies (XML for data description and HTTP for transport) to encode and transmit application data.

Consumers of a Web Service do not need to know anything about the platform, object model, or programming language used to implement the service; they only need to understand how to send and receive SOAP messages (HTTP and XML).

WCF Service

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data.

In what scenarios must WCF be used

  • A secure service to process business transactions.
  • A service that supplies current data to others, such as a traffic report or other monitoring service.
  • A chat service that allows two people to communicate or exchange data in real time.
  • A dashboard application that polls one or more services for data and presents it in a logical presentation.
  • Exposing a workflow implemented using Windows Workflow Foundation as a WCF service.

  • A Silverlight application to poll a service for the latest data feeds.

Features of WCF

  • Service Orientation.
  • Interoperability.
  • Multiple Message Patterns.
  • Service Metadata.
  • Data Contracts.
  • Security.
  • Multiple Transports and Encodings.
  • Reliable and Queued Messages.
  • Durable Messages.
  • Transactions.
  • AJAX and REST Support.
  • Extensibility.

Difference between Web Service in ASP.NET & WCF Service

WCF is a replacement for all earlier web service technologies from Microsoft. It also does a lot more than what is traditionally considered as "web services".

WCF "web services" are part of a much broader spectrum of remote communication enabled through WCF. You will get a much higher degree of flexibility and portability doing things in WCF than through traditional ASMX because WCF is designed, from the ground up, to summarize all of the different distributed programming infrastructures offered by Microsoft. An endpoint in WCF can be communicated with just as easily over SOAP/XML as it can over TCP/binary and to change this medium is simply a configuration file mod. In theory, this reduces the amount of new code needed when porting or changing business needs, targets, etc.

ASMX is older than WCF, and anything ASMX can do so can WCF (and more). Basically you can see WCF as trying to logically group together all the different ways of getting two apps to communicate in the world of Microsoft; ASMX was just one of these many ways and so is now grouped under the WCF umbrella of capabilities.

Web Services can be accessed only over HTTP & it works in stateless environment, where WCF is flexible because its services can be hosted in different types of applications. Common scenarios for hosting WCF services are IIS,WAS, Self-hosting, Managed Windows Service.

The major difference is that Web Services Use XmlSerializer. But WCF Uses DataContractSerializer which is better in Performance as compared to XmlSerializer.

Key issues with XmlSerializer to serialize .NET types to XML

  • Only Public fields or Properties of .NET types can be translated into XML.
  • Only the classes which implement IEnumerable interface.
  • Classes that implement the IDictionary interface, such as Hash table cannot be serialized.

Important difference between DataContractSerializer and XMLSerializer

  • A practical benefit of the design of the DataContractSerializer is better performance over Xmlserializer.
  • XML Serialization does not indicate which fields or properties of the type are serialized into XML whereas DataCotractSerializer.
  • Explicitly shows the which fields or properties are serialized into XML.
  • The DataContractSerializer can translate the HashTable into XML.

http://www.codeproject.com/Articles/139787/What-s-the-Difference-between-WCF-and-Web-Services