8.07.2012

WCF Difference FAQs-2

1.Difference between Self Hosting and IIS Hosting
S.No Self Hosting IIS Hosting
1
Coding Effort:

We need to add some extra code to host the process
Coding Effort:

No need to add extra code Automatic hosting
2
Deployment:

Easy to deploy
Deployment:

More difficult to deploy than Self-Hosting
3
Recycling:

Automatic process recycling is not possible
Recycling:

Automatic process recycling is possible
4
Service Lifetime:

Can control the service lifetime using Open and Close methods
Service Lifetime:

Lifetime cannot be controlled manually.
5
Host Process:

Host process should be running before client makes a call to the service.
Host Process:

IIS host runs automatically when a client makes a call to the service.


2.Difference between Behaviour and Contract
(OR)
Difference between Service Behaviour and Service Contract
S.No Service Contract Service Behaviour
1
Behaviour:

Affects the behavior of both client and server
Behaviour:

Only affects the behavior of the server
2
Applicability:

Can apply to both interface and class
Applicability:

Only applicable to a class implementation
3
Impact on WSDL:

Affects the WSDL emitted
Impact on WSDL:

Does not affect the WSDL
3.Difference between proxy and channel factory
S.No Proxy Channel Factory
1
Only requires URL where the service resides
We must have direct access to the assembly that contains that service contract T for
2
Very simpler
Not easier
3
Easy to understand
Channels are complex, network-related
4
There is Visual Studio gives us add the reference
When we share a common service contract dll between the client and the server, we will be using the ChannelFactory class
5
Proxies have several restrictions like:
  1. Properties need to have gets and sets
  2. Contructors cannot be exposed
  3. Methods other than the service contract cannot be exposed
If we know that our entities will not change much and the client code is less, then a DLL would work better than a proxy
6
By using SVCutil.exe we will create Proxy
When we are using DLL that refers Service contract interface then use the channel factory class


4.Difference between DataContractSerializer and XMLSerializer
S.No
DataContractSerializer
XMLSerializer
1
A practical benefit of the design of the DataContractSerializer is better performance over Xmlserializer. This is because DataContratSerializer explicitly shows the which fields or properties are serialized into XML.
XMLSerializer does not provide better performance when compare with DataContratSerializer because XMLSerializer does not indicate which fields or properties of the type are serialized into XML
2
The DataContractSerializer can translate the HashTable into XML.
XMLSerializer cannot translate the HashTable into XML.
3
DataContractSerializer is basically for very small, simple subset of the XML infoset.
XMLSerializer is used for complex schemas.
4
DataContractSerializer serializes private members.
XmlSerializer cannot serialize private members
5
DataContractSerializer uses the opts-in approach i.e, selecting the members that needs to be serialized .This is called as opts-in approach.
XmlSerializer uses opts-out approach i.e., marking the members do not need to be serialized. This is called as opts-out approach.
6
DataContractSerializer can serialize both private and public types.
XmlSerializer can serialize only public types. If we are trying to serialize a class that is marked private by InvalidOperation Exception will be thrown by the serializer.
7
DataContractSerializer does not need any default constructor before serializing any type.
For any types that needs to be serialized by XmlSerializer must have a default constructor.
8
DataContractSerializer does not give more control over the generated xml structure compared to the XmlSerializer.
XmlSerializer gives more control over the generated xml structure compared to the DataContractSerializer.
For ex, if a field should come as an attribute or element.
9
DataContractSerializer can able to serialize types that implements Idictionary.
XmlSerializer cannot able to serialize types that implements IDictionary, for ex. Dictionary type cannot be serialized.
10
We can serialize a type that marked with [Serializable] attribute with DataContractSerializer. It serializes all the members (private, public) even they are marked with [XmlIgnore].
Only the public members are serialized not the private members. Suppose we do not need any of the member to be serialized we can use [XmlIgnore] attribute
11
WCF uses DataContractSerializer attribute
Webservice uses XMLSerializer attribute

4 comments:

  1. please post the difference between wcf and web service

    ReplyDelete
    Replies
    1. Hi Vinod,

      Kindly look at the following URL to know the differences between WCF & Web Service,

      http://onlydifferencefaqs.blogspot.in/2012/07/wcf-difference-faqs-1.html

      Delete
  2. and also post difference between wpf and wcf

    ReplyDelete
    Replies
    1. Hi Vinod,

      Please look at the below URL for WPF vs WCF,

      http://www.c-sharpcorner.com/Interviews/answer/2751/what-is-the-difference-between-wpf-and-wcf

      Delete