We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Monday, March 16, 2015

Interview questions and answers of WCF



Q1. What is WCF?

WCF stands for Windows Communication Foundation. It is a Software development kit for developing services on Windows. WCF is introduced in .NET 3.0. in the System.ServiceModel namespace. WCF is based on basic concepts of Service-oriented architecture (SOA)

Q2. What is an endpoint in WCF service?

The endpoint is an Interface that defines how a client will communicate with the service. It consists of three main points: Address, Binding, and Contract.

Q3. Explain Address, Binding, and contract for a WCF Service?

Address: Address defines where the service resides.
Binding: Binding defines how to communicate with the service.
Contract: Contract defines what is done by the service.

Q4. What are the various address format in WCF?

a)HTTP Address Format:--> http://localhost:
b)TCP Address Format:--> net.tcp://localhost:
c)MSMQ Address Format:--> net.msmq://localhost:

Q5. What are the types of binding available in WCF?

A binding is identified by the transport it supports and the encoding it uses. Transport may be HTTP, TCP, etc and encoding may be text, binary, etc. The popular types of binding may be as below:
a)BasicHttpBinding
b)NetTcpBinding
c)WSHttpBinding
d)NetMsmqBinding

Q6. What are the types of contracts available in WCF?

The main contracts are:
a)Service Contract: Describes what operations the client can perform.
b)Operation Contract: defines the method inside the Interface of Service.
c)Data Contract: Defines what data types are passed
d)Message Contract: Defines whether a service can interact directly with messages.

Q7. What are the various ways of hosting a WCF Service?

a)IIS b)Self Hosting c)WAS (Windows Activation Service)

Q8. What is the proxy for WCF Service?

A proxy is a class by which a service client can Interact with the service.
By the use of proxy in the client application, we are able to call the different methods exposed by the service.

Q9. How can we create a Proxy for the WCF Service?

We can create a proxy using the tool svcutil.exe after creating the service.
We can use the following command at the command line.
svcutil.exe *.wsdl *.xsd /language:C# /out:SampleProxy.cs /config:app.config

Q10.What is the difference between WCF Service and Web Service?

a)WCF Service supports both Http and TCP protocol while webservice supports only HTTP protocol.
b)WCF Service is more flexible than web service.

Q11.What was the code name for WCF?

The code name of WCF was Indigo.
WCF is a unification of .NET framework communication technologies which unites the following technologies:-
1.Web services
2.MSMQ
3.NET remoting
4.COM+

Q12.What are the main components of WCF?

The main components of WCF are
1. Service class
2. Hosting environment
3. Endpoint

Q13.Where we can host WCF services?

Every WCF service must be hosted somewhere. There are three ways of hosting WCF services.
They are
1. IIS
2. Self Hosting
3. WAS (Windows Activation Service)

Q14.What is service and client in perspective of data communication?

A service is a unit of functionality exposed to the world.
The client of a service is merely the party consuming the service.

Q15.What are the different elements of the WCF Services Client configuration file?

WCF Services client configuration file contains endpoint, address, binding and contract.
A sample client config file looks like.

Q16.What is an endpoint in WCF?

Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint.

17. What are ends, contract, address, and bindings?

The above terminologies are the core on which SOA stands. Every service must expose one or
more ends by which the service can be available to the client. An end consists of three important
things where what and how:-
• Contract (What)
The contract is an agreement between two or more parties. It defines the protocol of how the client should
communicate with your service. Technically, it describes parameters and returns values for a
method.
• Address (Where)
An Address indicates where we can find this service. The address is a URL, which points to the
location of the service.
• Binding (How)
Bindings determine how this end can be accessed. It determines how communications is done.
For instance, you expose your service, which can be accessed using SOAP over HTTP or
BINARY over TCP. So for each of these communications medium, two bindings will be created.
Below the figure, show the three main components of the end. You can see the STOCK ticker
is the service
class, which has an end hosted on http://www.soa.com with HTTP and TCP binding support and using
STOCK Ticker interface type.

Q18.What is binding and how many types of bindings are there in WCF?

A binding defines how an endpoint communicates to the world. A binding defines the transport (such as HTTP or TCP) and the encoding being used (such as text or binary). A binding can contain binding elements that specify details like the security mechanisms used to secure messages or the message pattern used by an endpoint.

Q19.WCF supports nine types of bindings.

Basic binding
Offered by the BasicHttpBinding class, this is designed to expose a WCF service as a legacy ASMX web service, so that old client can work with new services. When used by the client, this binding enables new WCF clients to work with old ASMX services.
This binding is used when we need to use SOAP over HTTP. This binding
can also be configured to be used as HTTPS. It can be also configured to send data in plain text or
in an optimized form like MTOM.
TCP binding
Offered by the NetTcpBinding class, this uses TCP for cross-machine communication on the intranet. It supports a variety of features, including reliability, transactions, and security, and is optimized for WCF-to-WCF communication. As a result, it requires both the client and the service to use WCF.
This binding sends binary-encoded SOAP, including support for reliable
message transfer, security, and transactions, directly over TCP. The biggest disadvantage of NetTcpBinding is that both server and client should be also made in .NET language.

Peer network binding
Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast messages to it.

IPC binding
Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.

Web Service (WS) binding
Offered by the WSHttpBinding class, this uses HTTP or HTTPS for transport and is designed to offer a variety of features such as reliability, transactions, and security over the Internet.

It is the same as BasicHttpBinding. In short, it uses SOAP over HTTP. But with
it also supports reliable message transfer, security, and transaction. WS-Reliable Messaging,
security with WS-Security, and transactions with WS-Atomic Transaction support reliable
message.

Federated WS binding
Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security.

Duplex WS binding
Offered by the WSDualHttpBinding class, this is similar to the WS binding except it also supports bidirectional communication from the service to the client.

MSMQ binding
Offered by the NetMsmqBinding class, this uses MSMQ for transport and is designed to offer support for disconnected queued calls.

MSMQ integration binding
Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages and is designed to interoperate with legacy MSMQ clients.

This binding sends binary-encoded SOAP over MSMQ. This binding can
only be used for WCF-to-WCF communication.

No comments: