1. Difference between Self Hosting and IIS Hosting
Feature Self Hosting IIS Hosting
Coding Effort We need to add some extra code No need to add extra code
to host the process Automatic hosting
Deployment Easy to deploy More difficult to deploy than Self-
Hosting
Recycling Automatic process recycling is Automatic process recycling is
not possible possible
Service Lifetime Can control the service lifetime Lifetime cannot be controlled
using Open and Close methods manually.
Host Process Host process should be running IIS host runs automatically when a
before client makes a call to the client makes a call to the service.
service.
Difference between Behaviour and Contract
(OR)
Difference between Service Behaviour and Service Contract
Feature ServiceContract ServiceBehavior
Behaviour Affects the behavior of both Only affects the behavior of the
client and server server
Applicability Can apply to both interface and Only applicable to a class
class implementation
Impact on WSDL Affects the WSDL emitted Does not affect the WSDL
Difference between proxy and channel factory
Proxy Channel Factory
Only requires URL where the service resides We must have direct access to the assembly
that contains that service contract T for
Very simpler Not easier
Easy to understand Channels are complex, network-related
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
Proxies have several restrictions like: If we know that our entities will not change
1. Properties need to have gets and sets much and the client code is less, then a DLL
2. Contructors cannot be exposed would work better than a proxy
3. Methods other than the service contract
cannot be exposed
By using SVCutil.exe we will create Proxy When we are using DLL that refers Service
contract interface then use the channel
factory class
2. Difference between DataContractSerializer and XMLSerializer
DataContractSerializer XMLSerializer
A practical benefit of the design of the XMLSerializer does not provide better
DataContractSerializer is better performance performance when compare with
over Xmlserializer. This is because DataContratSerializer because XMLSerializer
DataContratSerializer explicitly shows the does not indicate which fields or properties of the
which fields or properties are serialized into type are serialized into XML
XML.
The DataContractSerializer can translate the XMLSerializer cannot translate the HashTable into
HashTable into XML. XML.
DataContractSerializer is basically for very XMLSerializer is used for complex schemas.
small, simple subset of the XML infoset.
DataContractSerializer serializes private XmlSerializer cannot serialize private members
members.
DataContractSerializer uses the opts-in XmlSerializer uses opts-out approach i.e., marking
approach i.e, selecting the members that the members do not need to be serialized. This is
needs to be serialized .This is called as opts- called as opts-out approach.
in approach.
DataContractSerializer can serialize both XmlSerializer can serialize only public types. If
private and public types. we are trying to serialize a class that is marked
private by InvalidOperation Exception will be
thrown by the serializer.
DataContractSerializer does not need any For any types that needs to be serialized by
default constructor before serializing any XmlSerializer must have a default constructor.
type.
DataContractSerializer does not give more XmlSerializer gives more control over the
control over the generated xml structure generated xml structure compared to the
compared to the XmlSerializer. DataContractSerializer.
For ex, if a field should come as an attribute or
element.
DataContractSerializer can able to serialize XmlSerializer cannot able to serialize types that
types that implements Idictionary. implements IDictionary, for ex. Dictionary type
cannot be serialized.
We can serialize a type that marked with Only the public members are serialized not the
[Serializable] attribute with private members. Suppose we do not need any of
DataContractSerializer. It serializes all the the member to be serialized we can use
members (private, public) even they are [XmlIgnore] attribute
marked with [XmlIgnore].
WCF uses DataContractSerializer attribute Webservice uses XMLSerializer attribute