Monday, August 06, 2012

Web Services Vs WCF



Before understanding the difference between Web Service And WCF lets see the background of each.

Web Service in ASP.NET

  • A Web Service is programmable application logic accessible via standard Web protocols like Simple Object Access Protocol (SOAP).

  • SOAP is a W3C standards technology that uses XML for data encode and transmit application data across the globe.

  • It is language as well as platform independent.

  • 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

  • WCF is a part of the .NET Framework that provides a unified programming model for rapidly building service-oriented applications that communicate across the web and the enterprise.

  • 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.

  • 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".


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


Scenario To Use WCF

  • 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.


Major Differences: Following are the major differences between Web services and WCF





















































FeaturesWeb ServiceWCF
HostingIt can be hosted in IISIt can be hosted in IIS, windows activation service, Self-hosting, Windows service
Programming[WebService] attribute has to be added to the class[ServiceContract] attribute has to be added to the class
Model[WebMethod] attribute represents the method exposed to client[OperationContract] attribute represents the method exposed to client
OperationOne-way, Request- Response are the different operations supported in web serviceOne-Way, Request-Response, Duplex are different type of operations supported in WCF
XMLSystem.Xml.serialization name space is used for serializationSystem.Runtime.Serialization namespace is used for serialization
EncodingXML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, CustomXML 1.0, MTOM, Binary, Custom
TransportsCan be accessed through HTTP, TCP, CustomCan be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
ProtocolsSecuritySecurity, Reliable messaging, Transactions
Multithreading SupportCan be multithreaded via ServiceBehaviour ClassCannot be multithreaded