Difference between Self Hosting and IIS Hosting Feature Coding Effort Deployment Recycling Service Lifetime Host
Process Self Hosting IIS Hosting extra code
We need to add some extra code No need to add to host the process Automatic hosting Easy to deploy
More difficult to deploy than SelfHosting process recycling be is
Automatic process recycling is Automatic not possible possible
Can control the service lifetime Lifetime cannot using Open and Close methods manually.
controlled
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 Behaviour Applicability Impact on WSDL
ServiceContract
ServiceBehavior
Affects the behavior of both Only affects the behavior of the client and server server Can apply to both interface and Only applicable class implementation Affects the WSDL emitted to a class
Does not affect the WSDL
Difference between proxy and channel factory Proxy Only requires URL where the service resides Very simpler Easy to understand There is Visual Studio gives us add the reference Channel Factory We must have direct access to the assembly that contains that service contract T for Not easier Channels are complex, network-related When we share a common service contract dll between the client and the server, we will be using the ChannelFactory class 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
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 By using SVCutil.exe we will create Proxy
When we are using DLL that refers Service contract interface then use the channel factory class
Difference between DataContractSerializer and XMLSerializer DataContractSerializer 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 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
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 members. serializes private XmlSerializer cannot serialize private 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 [Serializable] attribute with DataContractSerializer. It serializes all the members (private, public) even they are marked with [XmlIgnore]. WCF uses DataContractSerializer attribute 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 Webservice uses XMLSerializer attribute