Difference between WCF and Web Service
WCF |
Web Service |
To define WCF, ServiceContract, DataContract and OperationContract attributes are used
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
[DataContract]
public class CompositeType
{
bool boolValue = true;
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
}
public class Service1 : IService1
{
public string GetData(int value)
{
return value.ToString();
}
}
|
To define Web Service, WebMethod and WebService attributes are used.
[WebService]
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
|
| Supports different bindings like BasicHttp, WSHttpBinding,WSDualHttpBinding etc. | Used only SOAP and XML. |
| Hosted in IIS, Self Hosting, Windows Service, WAP(Windows Activation Service) | Hosted in IIS. |
| Access through HTTP, TCP, MSMQ, P2P, Named Pipes. | Access through HTTP. |
| Supports Security, reliable messaging, transactions, durable messages, service orientation, interoperability, service metadata, AJAX and REST support and extensibility | Supports only Security Services. |
| Use Service Metadata tool(svcutil.exe) to generate the client for service. | Uses command line tool WSDL.EXE to generate the client for service. |
| 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. | Unhandled exceptions are returned to the client as soap fault. |
| Generated WSDL can customized by using ServiceMetadataBehavior class. | Generated WSDL can be customized by using ServiceDescriptionFomratException class. |
| System.RunTime.Serailization is supported
* Better Performance |
System.XML.Serialization is supported. * Worst performance * Only Public fields or Properties of .NET types can be translated into XML. * Only the classes which implement IEnumerable and ICollection interface can be serialized. |
| Can be Multi-Threaded using ServiceBehavior class. | Can’t be Multi-Threaded. |
Hello friends, let me update if I have missed anything.