WCF Interview Questions and Answers (209) - Page 9

Which two in-built binding elements are required to use while implementing custom binding in you wcf service ?

NOTE: This is objective type question, Please click question title for correct answer.
What is Binding in WCF?

Binding describes how client will communicate with services. There are different protocols available to communicate to client. Binding has several characteristics :

Transport - Define base protocol to be used like HTTP, Named Pipes, TCP and MSMQ.

Encoding(Optional) - Three types of encoding available - Text, Binary or Message Transmission Optimization Mechanism(MTOM). MTOM is interoperable message format that allows the effective transmission of attachments or large message.

Protocol(Option) - Defines information to be used in Binding such as security transaction or reliable messaging capability.
What are types of Binding available in WCF?

BasicHttpBinding – It uses SOAP over HTTP.
WsHttpBinding – It uses SOAP over HTTP, it also supports reliable message transfer.
NetTcpbinding – It uses SOAP over TCP, but server and client should be in .Net.
NetNamedPipesBinding – It uses SOAP over Named Pipes.
Explain contract and all types of contract in WCF?

Contract is platform-neutral and standard way of describing what services does. In WCF, all services are exposed as contract. There are four types of contracts :

Service Contract – It describes operation provided by service. A service should contain at least one service contract. Service Contract is defined by using [ServiceContract] attribute , it is similar to [WebMethod] of Web Services.

Data Contract – It describes data exchange between service and client. Data Contract is defined using [DataContract] and [DataMember] attribute.

Message Contract – It transfers information from service to client. WCF uses SOAP message format for communication.

Fault Contract – It handles and convey error message to the client when service get error.
Difference between WCF and Web Service?

1) Web Services support hosting in IIS whereas WCF support hosting in IIS, WAS and Self-hosting.

2) Web Services can be invoked by Http whereas WCF service can be invoked by Http, Tcp, Named Pipes, MSMQ.

3) WCF Services are more reliable and secure as compare to Web Services.

4) WCF Services are more flexible as we make a new version of service we just have to expose a new endpoint.

5) In Web Service, [WebMethod] attribute specifies the method exposed to client. In WCF [OperationContract] attribute represents the method.
What is Service Host in WCF?

Service Host object is in process of hosting the WCF service and registering endpoints. It loads the service configuration endpoints, apply the settings. System.ServiceModel.ServiceHost namespace holds this object. This object is created while self hosting the WCF service.
There is scenerio, when one client has to access service SOAP using Http and other client have to access Binary using TCP, how can you acheive?

This can be acheived by adding extra endpoint in configuration file.

<endpoint address="http://locahost:8090/Service" contact="IMathService" binding="wsHttpBinding"/>
<endpoint address="net.tcp://locahost:8080/Service" contact="IMathService" binding="netTcpBinding"/>
What are advantages of WCF?

Advantages of WCF are :
WCF is interoperable with other services but .Net Remoting requires client and service in .Net.
WCF service provides better reliability and security as compare to Web Services.
In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small change in the configuration will make your requirement.
What is WCF?

WCF is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is latest service oriented technology. Interoperability is fundamental characteristic of WCF. WCF is combined feature of Web Service, Remoting, MSMQ, and COM+. WCF provides a common platform for all .NET communication.
In WCF, which binding is used for cross-machine communication or WCF-to-WCF communication?

NOTE: This is objective type question, Please click question title for correct answer.
What is the Extension of WCF service?

NOTE: This is objective type question, Please click question title for correct answer.
How many isolation levels are present and what are they?

1. READ UNCOMMITTED: - An uncommitted transaction can be read. This transaction can be rolled back later.
2. READ COMMITTED :- Will not read data of a transaction that has not been committed yet
3. REPEATABLE READ: - Locks placed on all data and another transaction cannot read.
4. SERIALIZABLE:- Does not allow other transactions to insert or update data until the transaction is complete.
How can we achieve overloading concept in WCF?

Yes, by using [OperationContract(Name="OverloadedName")] But, still outer world will get them with unique and different name. Overloading is a technique to write manageable/maintainable code. But in case of WCF service, uniqueness is required for generating WSDL, and that can be done either by using unique method name or unique OperationContract's name attribute value. Interfaces plays an important role and provides much flexibility for this. We can write many implementations of an interface, and it gives more flexibility plus concise. So why to think on overloading for WCF service methods?
In WCF, the type of contract used to define a class or an Interface is ?

NOTE: This is objective type question, Please click question title for correct answer.
In WCF, the type of contract used to define the method of a service is ?

NOTE: This is objective type question, Please click question title for correct answer.
In WCF, the type of contract used to define the data types passing on a service is ?

NOTE: This is objective type question, Please click question title for correct answer.
In WCF, the default type of binding is ?

NOTE: This is objective type question, Please click question title for correct answer.
In WCF, Binding of web services that supports duplex contract and transaction is ?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories