Following are the main difference between Web Service and
WCF (Window Communication Foundation) Service:
Features
|
Web
Service
|
WCF
|
File Extension
|
The file
extension is .asmx
|
The file
extension of WCF service is .svc
|
Programming
|
[WebService] attribute has to be added to the class
|
[ServiceContract] attribute has to be added to the class
|
Hosting
|
It
can be hosted in IIS
|
WCF
is flexible and it can be hosted in IIS, windows activation service,
Self-hosting, Windows service.
|
Serialization
|
Done
through XML serializer.
|
Done
through DataContractSerializer
|
Serialization
Namespace
|
System.XML.Serialization
|
System.RunTime.Serialization
|
Serialization
Differences
|
Hash
Table cannot be serialized.
Only
public properties/fields can be serialized
|
The
DataContractSerializer translate the Hash table into the XML.
Public/Private
properties/fields can be serialized.
|
Supported
Operations
|
One-way
and Request- Response.
|
One-Way,
Request-Response and Duplex
|
Binding
|
HTTP
|
HTTP,
WS-HTTP, TCP, Custom, Named Pipes, MSMQ, P2P (Point to Point).
|
Encoding
|
XML
1.0, MTOM (Message Transmission Optimization Mechanism), DIME, Custom
|
XML
1.0, MTOM, Binary, Custom
|
Model
|
[WebService] has to be added to the
class
[WebMethod]
attribute
represents the method exposed to the client.
|
[ServiceContract] attribute has to be
added to the class
[OperationContract]
attribute
represents the method exposed to the client.
|
Messaging
|
Uses
only SOAP (Simple Object Access Protocol)
|
It
can send/receive message in any transport protocol message format.
By default it uses SOAP for communication.
|
Security
|
Less
secured as compared to WCF. Using certificates we can protect the data but it
is complicated. Normally we use UserName/Password for security.
|
More
secured than WebServices. WCF does not need IIS to run, it can run as
a System Service on the Server, using a command ambient. WCF is a service and
not a Web Service.
|
Performance
(In terms of serialization)
|
Slower
than WCF
|
Better
than WebService.
|
State
Management
|
Web
services are by nature stateless.
|
WCF
service can maintain state and session
|
Exception
Handling
|
Unhandled
Exceptions returns to the client as SOAP faults.
|
Unhandled
Exceptions does not return to the client as SOAP faults. A configuration setting
is provided to have the unhandled exceptions returned to the Client for the
purpose of debugging.
|
I disagree! although we hardly ever host ASMX out of IIS but if we want there are multiple options available for the same. One of them being cassini web server, for more please refer below msdn link:
ReplyDeletehttp://msdn.microsoft.com/en-us/magazine/cc163879.aspx
@Ravi..thanks for the details yes we can host web service with Cassini web server, but it's a workaround to host the service, and here I have included only basic differences and didn't dig in advance..:)
ReplyDeletesd
ReplyDelete