Saturday, August 1, 2009

WCF Vs WebServices

WCF

1. DataContractSerializer is used for data transition.

2. File extension is .svc

3. The WCF uses the DataContractAttribute and DataMemeberAttribute to translate .NET FW types in to XML.

4. Public/Private fields or properties of .NET types can be translated.

5. The DataContractSerializer can translate the Hash Table into XML. Hence using WCF we can even translate HashTable into XML.

6. The main benefit of the design of the DataContractSerializer is better performance over XML serialization.

7. DataCotractSerializer Explicitly shows the which fields or properties are serialized into XML.

8. In WCF Services, unhandled exceptions are not returned to clients as SOAP faults. A configuration setting is provided to have the unhandled exceptions returned to clients for the purpose of debugging.

[ServiceContract]
public interface ITest
{
[OperationContract]
string ShowMessage(string strDemo);
}
public class Service : ITest
{
public string Demo(string strDemo)
{
return strDemo;
}
}


ASP.NET Web Service

1. To and from Data Transition is done through XML Serializer.

2. File extention is asmx.

3. ASP.NET WebService uses Webmethods to to translate .NET FW types in to XML.
4. Only Public fields or Properties of .NET types can be translated into XML.Only the classes which implement IEnumerable interface, ICollection interface can be serializable.

5. Classes that implement the IDictionary interface, such as Hash table can not be serialized.

6. Slower compared to WCF.

7. XMLSerialization does not indicate the which fields or properties of the type are serialized into XML.

8. In ASP.NET Web services, Unhandled exceptions are returned to the client as SOAP faults.

[WebService]
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string Demo(string strDemog)
{
return strDemo;
}
}

No comments: