Difference between WCF and WebServices
Posted on February 15th , 2012 by Admin
|
|
(1)We can host Webservice only in IIS on other side WCF can be hosted in IIS,Self-hosting,Windows Service, windows activation service etc. So WCF is more flexible and useful than webservice.
(2)When we talk about binding Webservice supports only the http binding while WCF supports HTTP,TCP,MSMQ Bindings.
(3)Web service only supports one way and request response operations while WCF supports one way ,request response and Duplex communication as well and in client server scenario a duplex WCF service is a service where the server can send messages to the client without the client requesting them. In the scenarios when an event taking place on the server should send a message to your client we should use Duplex WCF service.For example a third party application sending message to your service and your service must inform itas client after receiving third party message.
(4) WebService used System.Xml.serialization for serialization but in WCF System.Runtime.Serialization namespace ( DataContractSerializer class) is used for serialization.This serializatiobn used in WCF gives better performance. System.Xml.serialization is called XML serialization while System.Runtime.Serialization namespace that works like Binary serialization.
(5)When we talk about encoding WebServices supports XML and Custom Encoding but WCF supports XML,Custom and Binary Encoding as well. An Encoding is a set of rules to present messages on the wire.
In other words Encoding is a process of converting a message into an array of bytes. Encoding should not be confused with serialization Serialization defines how the .NET object maps to XML,while Encoding defines how the XML is written out to a stream of bytes
(6)In web service the attribute used for service class is (WebService) while in WCF the attribute used for service class is (ServiceContract)
(7)WCF has an integrated Logging mechanism that enables us to log traces without writing code for it. Web service does not have this facility. changing the configuration file settings in WCF provides logging functionality.To use Integrated logging mechanism of WCF you need to enable message logging in WCF and enable ASP.NET tracing.
(8) WCF has more options for security as compare to web service. The options for securing ASP.NET Web services are those for securing any IIS application but the options for securing WCF applications are independent from the facilities of IIS because it had to cater to other (tcp ,mamq and of course http) protocol other than http from security perspective so WCF has all the security options of webservice and additionally it has other security options of other type of hosting and or underlying implementation(tcp msmq etc). Also for mostly used bindings WCF provides default security which can be trusted like message security on WSHTTPbinding.
(9)WCF is faster than ASP.NET Web Services Because The DataContractSerializer(Binary like) used in WCF has better performance advantages over XML serialization used in webservice so WCF service is faster than ASP.NET webservice.
(10)WCF supports Atomic Transactions while Webservice does not support atomic transaction. WS-Atomic protocol is used to handle transactions in WCF Using this protocol different WCF services hosted on different servers togather can participate in transaction.
(11)WCF can maintain Session easily while in webservice lots of code has to be written for that.
(12)WCF provides AJAX and JSON(java script object notation) integration support but web service does not have it.Thus WCF services can expose operations to AJAX clients.AJAX clients are Web pages running Javascript code and accessing these WCF services using HTTP requests.
(13)Web services Unhandled exceptions are returned to the client as SOAP faults. WCF Services unhandled exceptions are not returned to clients as SOAP faults. We need to do a configuration setting for the unhandled exceptions to return to clients for debugging. |
|
|