Home > WCF > WCF #20 – Compare WCF and web services /Difference between WCF and web services / WCF vs. Web services

WCF #20 – Compare WCF and web services /Difference between WCF and web services / WCF vs. Web services

Hi Geeks,

In this post we will see measure differences between the WCF and web services and will compare them on important aspects.

WCF [Windows Communication Foundation]

WCF provides a common platform for all .NET communication.

It is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is the latest service oriented technology; Interoperability being one of its fundamental characteristics.   It is a combined set of features including Web Services, Remoting, MSMQ and COM+.

The figure below shows the different technologies combined to form WCF.

image

ASMX Web Services

These are published, described and located over Internet. An ASMX web service is a collection of protocols and standards used for exchanging data between applications or systems with following characteristics:


1. A Web Service is a piece of executable code that is accessible over the Web.

2. A Web Service can communicate using platform-independent and language-neutral Web protocols.

3. A Web Service can share schemas and contracts/interface which in turn can be called from another program.

4. A Web Service can be registered and located through a Web Service Registry.

5. A Web Service supports loosely coupled connections between systems.

Conceptual Differences

The conceptual difference between WCF and ASMX Services can be highlighted under following points

1. Protocols Support

  • WCF
    • HTTP
    • TCP
    • Named pipes
    • MSMQ
    • Custom
    • UDP
  • ASMX

             Http Only

2.Hosting 

  • ASMX
    • Can be hosted only with HttpRuntime on IIS.
  • WCF
    • A WCF component can be hosted in any kind of environment in .NET 3.0, such as a console application, Windows application, or IIS.
    • WCF services are known as ‘services’ as opposed to web services because one can host services outside of a web (HTTP) server.
    • Self-hosting the services gives one the flexibility to use transports other than HTTP

Advantages of WCF over ASMX Services

1. Better Interoperability

WCF is interoperable with other services when compared to .Net Remoting,where the client and service have to be .Net.

2. End-to-End Reliability and Security:

WCF services provide better reliability and security in comparison to ASMX web services.

3. Configuration based security and binding:

In WCF, there is no need to make changes in code for implementing the security model or changing the binding. Small configuration changes are all that is needed.

4. Integrated Logging:

WCF has an integrated logging mechanism, changing the configuration file settings provides logging functionality. In ASMX (and other technologies), one has to write logging specific code.

5. Multiple Protocols:

WCF works across multiple protocols including http, tcp, MSMQ etc where as ASMX services can only use http.

6. Transactional Capability:

WCF can create and maintain transactions like com+ .

7. Hosting Options:

WCF services can be hosted on IIS, Self hosting, Windows Services(Windows Application Service) and even console apps, WinForms apps etc.

8. Better Interoperability through Data Contracts

The development of web service with ASP.net relies on defining data and relies on the XMLSerializer to transform data to or from a service.  WCF Uses DataContractAttribute and DataMember attributes to Translate .net types to XML.
DataContract attributes can be used for classes and structures-DataMember Attribute to Field or Property
The differences between DataContractSerailizer and XML Serializer include: 
DCS has better performance over XML Serialization
– XML Serialization doesn’t indicate which field or property of the type is serialized, DCS Explicitly shows which field or property is serialized
– DCS can serialize classes implementing IDictionary interface(Hash Table)

9. Exception Handling

In ASP.NET Web services, Unhandled exceptions are returned to the client as SOAP faults. 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.

 

Limitations of ASMX:

An ASMX page doesn’t tell you how to deliver it over the transports or to use a specific type of security.  WCF lets you choose that easily via configuration parameters.

ASMX is tightly coupled to the HTTP runtime and has a strong dependence on IIS to host it. WCF can be hosted by any Windows process that is able to host the .NET Framework 3.0.

ASMX services are instantiated on a per-call basis, while WCF gives one the flexibility by providing various instantiating options such as singleton, private session, per call.

ASMX provides the way for interoperability but it does not provide guaranteed end-to-end security or reliable communication.  WCF provides both end-to-end reliability as well as security.

Summary :

image

 

Thank You.

Smile 

Advertisements
Categories: WCF
  1. Chi
    June 24, 2013 at 7:59 pm

    I am in fact grateful to the holder of this site who has shared this
    enormous post at at this time.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: