Wednesday, October 27, 2010

WCF vs WebServices

What is really the difference between ASP.NET web service and WCF service?
Before we jump in too detail, few important things to remember about the service architecture

Web Service (.asmx) relies on XMLSeralizer object to transform data back and forth.
Only Public types and properties can be transformed using Web Service
it supports classes that implements IEnumerable interface and do not support classes that implements IDictionary object Such as HashTable.

WCF on the other hand uses DataContractSerializer, it uses DataContractAttribute and DataMemberAttribute to translate .Net Types to XML. DataContractSerializer can transform IDictionary obejct.

The main contracts that makes WCF powerful are
DataContract : Defines the structure of data included in the payloads of the messages flowing in and out of the service
Service Contract : Defines which operations the service makes available to be invoked as request messages are sent to the service from the client
Message Contract: Enables you to control the headers that appear in the messages and how the messages are structured
Fault Contract : Service methods communicate processing using SOAP fault messages. SOAP faults are message types that are included in the metadata for a service operation and these exceptions can be handled via Fault contract.

Creating Proxy Object for Client Consumption of the service:
WSDL.EXE tool is used by consuming application to create Web services proxy object or class..
SVCUTIL.EXE is used by consuming application to create WCF proxy object or class.

No comments:

Post a Comment