In this topic, I will list the details lists 10 differences items for you
WCF
[ServiceContract] public interface IHelloService { [OperationContract] void DoWork(); [OperationContract] string GetMessage(string name); }
public class HelloService : IHelloService { public void DoWork() { } public string GetMessage(string name) { return "Welcome: " + name; } }
ASP.NET Web Services
[WebSerivce] public class Service: System.Web.Services.WebService { [WebMethod] public string Test() { return "Hello world!"; } }
WCF | ASP.NET Web Services |
---|---|
Hosted in IIS, WAS (Windows Activation Service), Self-hosting, Windows service | Hosted in IIS |
Accessed through HTTP, TCP, MSMQ, P2P, Named pipes | Accessed through HTTP only |
Support security, reliable messaging, transactions, durable messages, service orientation, interoperability, service metadata, AJAX and REST support, extensibility |
Supports security services |
Uses the ServiceMeta data tool (svcutil.exe) to generate the client for the service | Uses the command-line tool WSDL.exe to generate the client for the 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 faults |
The generated WSDL can customized by using ServiceMeta data Behavior class | The generated WSDL can customized by using ServiceDescriptionFormatExtension class |
System.RunTime.Serialization is supported. - Better performance. - DataContractAttribute and DataMemberAttribute can be added to .NET Framework types to indicate that instances of the type are to be serialized into XML, and which particular fields or properties of the type are to be serialized. - Classes that implement the IDictionary interface can be serialized. - Hash table can be serialized. |
System.XML.Serialization is supported - Worse 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. - Hash table can not be serialized. |
Can be multithreaded via ServiceBehavior class | Can not be multithread. |
Supports different type of bindings like BasicHttpBinding, WSHttpBinding, WSDualHttpBinding etc. |
Only used SOAP or XML for this. |