YouTube Icon

Interview Questions.

Top 100+ Windows Communication Foundation (wcf) Interview Questions And Answers - May 25, 2020

fluid

Top 100+ Windows Communication Foundation (wcf) Interview Questions And Answers

Question 1. What Is Wcf?

Answer :

Windows Communication Foundation (WCF) is an SDK for growing and deploying offerings on Windows. WCF gives a runtime surroundings for services, allowing you to reveal CLR types as offerings, and to eat other offerings as CLR types.

WCF is part of .NET 3.Zero and requires .NET 2.0, so it can simplest run on systems that help it.

Question 2. What Is Service And Client In Perspective Of Data Communication?

Answer :

A service is a unit of capability exposed to the sector.

VB.NET Interview Questions
Question three. What Is Address In Wcf And How Many Types Of Transport Schemas Are There In Wcf?

Answer :

Address is a way of letting customer recognize that in which a carrier is located. In WCF, each service is associated with a unique deal with. This contains the area of the provider and shipping schemas.

WCF supports following transport schemas

HTTP
TCP
Peer community
IPC (InterProcess
Communication over named pipes)
MSMQ

Question 4. What Are Contracts In Wcf?

Answer :

In WCF, all offerings divulge contracts. The agreement is a platformneutral and widespread way of describing what the service does.

WCF defines four sorts of contracts.

Service contracts: Describe which operations the customer can carry out on the provider.

There are  varieties of Service Contracts.

ServiceContract This attribute is used to define the Interface.
OperationContract This attribute is used to define the approach internal Interface.
Data contracts: Define which facts types are exceeded to and from the provider. WCF defines implicit contracts for builtin kinds including int and string, but we are able to effortlessly define specific optin statistics contracts for custom sorts.

There are two sorts of Data Contracts.

DataContract attribute
used to outline the class
DataMember characteristic
used to define the properties.
Fault contracts: Define which errors are raised by using the carrier, and how the carrier handles and propagates mistakes to its customers.

Message contracts: Allow the carrier to engage without delay with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an present message layout we must follow.

VB.NET Tutorial
Question 5. Where We Can Host Wcf Services?

Answer :

Every WCF services should be hosted somewhere. There are 3 approaches of web hosting WCF offerings.

They are

IIS
Self Hosting
WAS (Windows Activation Service)
C#. NET Interview Questions
Question 6. What Is Binding And How Many Types Of Bindings Are There In Wcf?

Answer :

A binding defines how an endpoint communicates to the arena. A binding defines the shipping (along with HTTP or TCP) and the encoding getting used (which include textual content or binary). A binding can comprise binding elements that specify info like the security mechanisms used to relaxed messages, or the message sample utilized by an endpoint.

WCF supports nine sorts of bindings.

Basic binding: Offered by using the BasicHttpBinding elegance, this is designed to expose a WCF service as a legacy ASMX internet provider, in order that vintage clients can paintings with new offerings. When used by the client, this binding enables new WCF clients to work with vintage ASMX offerings.
TCP binding: Offered by the NetTcpBinding elegance, this uses TCP for crossmachine communique at the intranet. It helps a variety of functions, along with reliability, transactions, and security, and is optimized for WCFtoWCF communication. As a end result, it calls for each the customer and the carrier to apply WCF.
Peer network binding Offered via the NetPeerTcpBinding elegance, this makes use of peer networking as a shipping. The peer networkenabled consumer and offerings all enroll in the same grid and broadcast messages to it.
IPC binding: Offered by means of the NetNamedPipeBinding magnificence, this makes use of named pipes as a transport for samemachine communique. It is the maximum secure binding because it can't be given calls from outside the gadget and it supports a ramification of capabilities similar to the TCP binding.
Web Service (WS) binding: Offered by way of the WSHttpBinding magnificence, this makes use of HTTP or HTTPS for delivery, and is designed to offer an expansion of capabilities such as reliability, transactions, and protection over the Internet.
Federated WS binding: Offered by means of the WSFederationHttpBinding class, that is a specialization of the WS binding, offering aid for federated protection.
Duplex WS binding: Offered through the WSDualHttpBinding elegance, that is similar to the WS binding except it also supports bidirectional verbal exchange from the provider to the consumer.
MSMQ binding: Offered via the NetMsmqBinding magnificence, this makes use of MSMQ for delivery and is designed to offer assist for disconnected queued calls.
MSMQ integration binding: Offered with the aid of the MsmqIntegrationBinding elegance, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients.
Question 7. What Is Endpoint In Wcf?

Answer :

Every provider should have Address that defines where the carrier is living, Contract that defines what the carrier does and a Binding that defines the way to communicate with the service. In WCF the relationship between Address, Contract and Binding is known as Endpoint.

C#. NET Tutorial Adv Java Interview Questions
Question eight. How To Define A Service As Rest Based Service In Wcf?

Answer :

WCF three.Five provides explicit aid for RESTful conversation the usage of a new binding named WebHttpBinding.

The beneath code suggests how to reveal a RESTful service

[ServiceContract]
interface IStock

[OperationContract]
[WebGet]
int GetStock(string StockId);


Question nine. What Is The Address Formats Of The Wcf Transport Schemas?

Answer :

Address format of WCF delivery schema constantly follow

[transport]://[machine or domain][:optional port] format.

As an instance:

HTTP Address Format

http://localhost:8888

the way to study the above url is

"Using HTTP, go to the system called localhost, where on port 8888 someone is waiting"

When the port wide variety is not designated, the default port is 80.

TCP Address Format

net.Tcp://localhost:8888/MyService

When a port number isn't always distinctive, the default port is 808:

internet.Tcp://localhost/MyService

NOTE: Two HTTP and TCP addresses from the identical host can proportion a port, even on the identical machine.

IPC Address Format

internet.Pipe://localhost/MyPipe

We can only open a named pipe as soon as according to system, and consequently it is not feasible for two named pipe addresses to percentage a pipe call at the identical machine.

MSMQ Address Format

internet.Msmq://localhost/private/MyService

internet.Msmq://localhost/MyService

SQL Server 2008 Interview Questions
Question 10. What Is Proxy And How To Generate Proxy For Wcf Services?

Answer :

The proxy is a CLR class that exposes a unmarried CLR interface representing the service agreement. The proxy provides the same operations as service's contract, but also has extra techniques for dealing with the proxy lifestyles cycle and the relationship to the carrier. The proxy absolutely encapsulates every thing of the service: its location, its implementation technology and runtime platform, and the communication delivery.

The proxy may be generated the usage of Visual Studio by proper clicking Reference and clicking on Add Service Reference. This brings up the Add Service Reference conversation field, where you want to deliver the bottom address of the service (or a base address and a MEX URI) and the namespace to comprise the proxy.

Proxy can also be generated with the aid of using SvcUtil.Exe commandline utility. We want to offer SvcUtil with the HTTPGET deal with or the metadata trade endpoint address and, optionally, with a proxy filename. The default proxy filename is output.Cs but you could also use the /out switch to signify a exceptional name.

SvcUtil http://localhost/MyService/MyService.Svc /out:Proxy.Cs

When we're website hosting in IIS and deciding on a port aside from port eighty (such as port 88), we ought to offer that port quantity as part of the bottom address:

SvcUtil http://localhost:88/MyService/MyService.Svc /out:Proxy.Cs

Adv Java Tutorial
Question 11. What Are Different Elements Of Wcf Srevices Client Configuration File?

Answer :

WCF Services customer configuration file includes endpoint, address, binding and contract. A pattern customer config report seems like

<system.ServiceModel>
<client>
<endpoint name = "MyEndpoint"
address = "http://localhost:8000/MyService/"
binding = "wsHttpBinding"
contract = "IMyContract"
/>
</client>
</system.ServiceModel>

ASP.NET Interview Questions
Question 12. What Is Transport And Message Reliability?

Answer :

Transport reliability (such as the only supplied with the aid of TCP) offers pointtopoint assured transport at the network packet level, in addition to guarantees the order of the packets. Transport reliability isn't resilient to losing network connections and a variety of other communique troubles.

Message reliability offers with reliability on the message stage impartial of how many packets are required to deliver the message. Message reliability gives for endtoend guaranteed transport and order of messages, no matter what number of intermediaries are involved, and what number of community hops are required to supply the message from the purchaser to the service.

VB.NET Interview Questions
Question thirteen. How To Configure Reliability While Communicating With Wcf Services?

Answer :

Reliability can be configured inside the client config report by adding reliableSession beneath binding tag.

<system.ServiceModel>
<services>
<service name = "MyService">
<endpoint
address = "net.Tcp://localhost:8888/MyService"
binding = "netTcpBinding"
bindingConfiguration = "ReliableCommunication"
contract = "IMyContract"
/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name = "ReliableCommunication">
<reliableSession enabled = "true"/>
</binding>
</netTcpBinding>
</bindings>
</system.ServiceModel>

Reliability is supported by way of following bindings simplest

NetTcpBinding
WSHttpBinding
WSFederationHttpBinding
WSDualHttpBinding

SQL Server 2008 Tutorial
Question 14. How To Set The Timeout Property For The Wcf Service Client Call?

Answer :

The timeout assets may be set for the WCF Service purchaser call the usage of binding tag.

<client>
<endpoint
...
Binding = "wsHttpBinding"
bindingConfiguration = "LongTimeout"
...
/>
</client>
<bindings>
<wsHttpBinding>
<binding name = "LongTimeout" sendTimeout = "00:04:00"/>
</wsHttpBinding>
</bindings>

If no timeout has been particular, the default is considered as 1 minute.

Question 15. How To Deal With Operation Overloading While Exposing The Wcf Services?

Answer :

By default overload operations (techniques) are not supported in WSDL based totally operation. However via the use of Name assets of OperationContract attribute, we are able to deal with operation overloading situation.

[ServiceContract]
interface ICalculator

[OperationContract(Name = "AddInt")]
int Add(int arg1,int arg2);
[OperationContract(Name = "AddDouble")]
double Add(double arg1,double arg2);


Notice that both approach call in the above interface is identical (Add), but the Name assets of the OperationContract is distinct. In this case consumer proxy can have  strategies with exceptional call AddInt and AddDouble.

Windows Administration Interview Questions
Question 16. What Was The Code Name For Wcf?

Answer :

The code call of WCF turned into Indigo .

WCF is a unification of .NET framework conversation technology which unites the subsequent technologies:

NET remoting
MSMQ
Web offerings
COM+
ASP.NET Tutorial
Question 17. What Are The Main Components Of Wcf?

Answer :

The major additives of WCF are

Service class
Hosting environment
End point
SSRS(SQL Server Reporting Services) Interview Questions
Question 18. What Are Various Ways Of Hosting Wcf Services?

Answer :

There are 3 predominant approaches of website hosting a WCF offerings

Selfhosting the carrier in his own application domain. This we've already covered inside the first phase. The provider comes in to lifestyles when you create the object of Service Host class and the carrier closes whilst you name the Close of the Service Host class.
Host in utility area or procedure provided by means of IIS Server.
Host in Application domain and technique provided by WAS (Windows Activation Service) Server.
C#. NET Interview Questions
Question 19. What Is The Difference Wcf And Web Services?

Answer :

Web offerings can most effective be invoked by using HTTP (conventional webservice with .Asmx). While WCF Service or a WCF component can be invoked with the aid of any protocol (like http, tcp and so on.) and any shipping type.

Second web services are not bendy. However, WCF Services are flexible. If you make a new edition of the carrier then you definately want to simply disclose a brand new stop. Therefore, offerings are agile and which is a completely practical method looking at the cutting-edge enterprise trends.

We expand WCF as contracts, interface, operations, and statistics contracts. As the developer we are more focused at the enterprise good judgment offerings and need now not fear approximately channel stack. WCF is a unified programming API for any sort of offerings so we create the carrier and use configuration records to set up the communique mechanism like HTTP/TCP/MSMQ and so forth

LINQ Tutorial
Question 20. What Is Three Major Points In Wcf?

Answer :

We Should recollect ABC.

Address Specifies the location of the provider if you want to be like http://Myserver/MyService.Clients will use this region to communicate with our provider.

Binding Specifies how the two paries will talk in term of transport and encoding and protocols

Contract Specifies the interface between customer and the server.It's a easy interface with a few characteristic.

LINQ Interview Questions
Question 21. What Are The Various Ways Of Hosting A Wcf Service?

Answer :

Self website hosting the service in his own software area. This we've got already included in the first segment. The provider is available in to lifestyles when you create the object of ServiceHost magnificence and the service closes whilst you name the Close of the ServiceHost magnificence.

Host in utility area or system furnished by using IIS Server.

Host in Application area and technique furnished by way of WAS (Windows Activation Service) Server.

Question 22. Difference Between Wcf And Web Services?

Answer :

Web Services

It Can be accessed only over HTTP
It works in stateless environment
WCF

WCF is bendy due to the fact its services can be hosted in extraordinary forms of applications. The following lists several common situations for web hosting WCF services:

IIS
WAS
Selfhosting
Managed Windows Service
Windows Presentation Foundation(WPF) Tutorial
Question 23. What Is A Soa Service?

Answer :

SOA is Service Oriented Architecture. SOA provider is the encapsulation of a high level business concept. A SOA carrier is composed of 3 components.

A service elegance enforcing the carrier to be furnished.
An environment to host the carrier.
One or more endpoints to which customers will join.
Windows Presentation Foundation(WPF) Interview Questions
Question 24. What Is The Use Of Servicebehavior Attribute In Wcf ?

Answer :

ServiceBehaviour attribute is used to specify the InstanceContextMode for the WCF Service elegance (This may be used to maintained a state of the service or a client too)

There are 3 example Context Mode inside the WFC

PerSession : This is used to create a brand new example for a service and the same example is used for all technique for a selected patron. (eg: State can be maintained according to consultation by way of asserting a variable)

PerCall : This is used to create a brand new instance for each name from the purchaser whether or not same patron or extraordinary. (eg: No state may be maintained as each time a new example of the provider is created)

Single : This is used to create most effective one instance of the provider and the identical example is used for all of the patron request. (eg: Global nation can be maintained but this could be applicable for all clients)

Adv Java Interview Questions
Question 25. In Wcf, Which Contract Is Used To Document The Errors Occurred In The Service To Client?

Answer :

Fault Contract is used to document the mistakes passed off inside the service to consumer.

Windows Server 2012 Tutorial
Question 26. What Is The Messaging Pattern? Which Messaging Pattern Wcf Supports?

Answer :

Messaging Pattern : Messaging styles describes how patron and server should change the message. There is a protocol among purchaser and server for sending and receiving the message. These are also called Message Exchange Pattern.

WCF supports following 3 types of Message Exchange Patterns

request reply- (default message trade pattern)
OneWay (Simplex / datagram)
Duplex(CallBack)
Advanced C# Interview Questions
Question 27. What Is .Svc File In Wcf?

Answer :

.Svc record is a text document. This document is similar to our .Asmx file in internet offerings.

This record incorporates the details required for WCF carrier to run it efficiently.

This report includes following information :

Language (C# / VB)
Name of the provider
Where the carrier code resides
Example of .Svc report

<%@ ServiceHost Language="C#/VB" Debug="authentic/false" CodeBehind="Service code files course" Service="ServiceName"

SQL Server 2008 Interview Questions
Question 28. What Is Xml Infoset?

Answer :

The XML Information Set defines a facts version for XML. It is an abstract set of standards such as attributes and entities that may be used to explain a legitimate XML document. According to the specification, "An XML file's data set includes some of data objects? the facts set for any wellformed XML record will incorporate as a minimum a document information item and numerous others."

Question 29. What Is Datacontractserializer In Wcf?

Answer :

DataContractSerializer is new WCF serializer.

This is serialization engine in WCF. DataContractSerializer translate the .NET framework gadgets into XML and viceversa.

By default WCF uses DataContractSeriazer.

Advanced jQuery Interview Questions
Question 30. What Is Message Contract In Wcf?

Answer :

Message Contract : Message Contract is the way to manipulate the SOAP messages, despatched and received by using the purchaser and server.

Message Contract can be used to add and to get the custom headers in SOAP message Because of Message Contract we will customise the parameters sent using SOAP message among the server and consumer.

Question 31. What Is Fault Contracts In Wcf?

Answer :

Fault Contracts is the way to handle exceptions in WCF. The hassle with exceptions is that those are era particular and consequently cannot be handed to different cease due to interoperability difficulty. (Means either from Client to Server or viceversa).

There should be every other manner representing the exception to support the interoperability. And right here the SOAP Faults comes into the photograph.

Soap faults are not specific to any precise generation and they're based totally on enterprise standards.

To aid SOAP Faults WCF offers FaultException magnificence. This magnificence has  bureaucracy:

FaultException : to ship untyped fault back to customer
FaultException<T>: to ship typed fault information to the customer
WCF carrier also gives FaultContract attribute in order that developer can specify which fault can be despatched via the operation (method). This attribute can be implemented to operations simplest.

Question 32. What Is The Difference Between Xmlserializer And The Datacontractserializer?

Answer :

DataContractSerializer is the default serializer fot the WCF
DataContractSerializer could be very fast.
DataContractSerializer is essentially for extremely small, easy subset of the XML infoset.
XMLSerializer is used for complicated schemas.
Asp Dot Net Mvc 4 Interview Questions
Question 33. What Is The Purpose Of Base Address In Wcf Service? How It Is Specified?

Answer :

When a couple of endpoints are related to WCF provider, base deal with (one primary cope with) is assigned to the carrier, and relative addresses are assigned to every endpoint. Base cope with is specified in <host> element for every service.

E.G.

<configuration>
<system.Servicemodel>
<Services>
<service name=”MyService>
<host>
<baseAddresses>
<add baseAddress =”http://localhost:6070/MyService”>
</baseAddresses>
</host>
</service>
<services>
</system.Servicemodel>
</configuration>

ASP.NET Interview Questions
Question 34. Which Protocol Is Used For Platformindependent Communication?

Answer :

SOAP (Simple Object Access Protocol), that's directly supported from WCF (Windows Communication Foundation).

Question 35. What Is Abc Of Wcf?

Answer :

ABC is the 3 building blocks of WCF and they're called

A Address (Where): Address tells us wherein to discover the services, like url

B Bindings (How): Bindings tells us a way to locate the offerings or using which protocols unearths the offerings (SOAP, HTTP, TCT and many others.)

C Contacts (What): Contracts are an settlement between the patron and the service vendors that explains what parameters the provider expects and what go back values it offers.

Question 36. How The Concurrency Mode Is Specified In Wcf Service?

Answer :

The concurrency mode is specific the use of the ServiceBehavior characteristic at the magnificence that implements the service.

Ex.

[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Single)]
Public class ServiceClass : IServiceInterface
//Implementation Code


There are 3 possible values of ConcurrencyMode enumeration

Single
Reentrant
Multiple
Windows Administration Interview Questions
Question 37. Which Are The three Types Of Transactions Manager Wcf Supports?

Answer :

WCF helps following 3 kinds of transactions managers:

LightWeight
OLE Transactions
WSAtomic Transactions
Question 38. Which Bindings In Wcf Support The Message Streaming?

Answer :

Following bindings supports the streaming in WCF:

basicHttpBinding
netTcpBinding
netNamedPipeBinding
Question 39. How To Set The Instancing Mode In Wcf Service?

Answer :

In WCF, instancing mode is ready at carrier degree. For ex.

//Setting PerSession example mode
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
magnificence MyService : IMyService

//Implementation goes there


Question 40. What Is Address Header In Wcf?

Answer :

Address Header carries the statistics that is despatched with every request, it can be utilized by either give up factor service or any intermediate device for determining any routing common sense or processing good judgment.

WCF offers AddressHeader magnificence for this reason.

Example :

AddressHeader addressHeader= AddressHeader.CreateAddressHeader("Name of the header", "Information included in header ");

Once the AddressHeader instance is created, it could be related to quit point example as follows :

EndpointAddress endpoint = new EndpointAddress(new Uri("http://myserver/myservice"), addressHeader);

SSRS(SQL Server Reporting Services) Interview Questions
Question forty one. In Wcf Which Bindings Supports The Reliable Session?

Answer :

In WCF, following bindings supports the dependable consultation

wsHttpBinding
wsDualHttpBinding
wsFederationHttpBinding
netTcpBinding
Question forty two. What Are Tha Advantages Of Hosting Wcf Service In Was?

Answer :

WAS (Windows Activation Service) is part of IIS 7.0. Following are few blessings :

We are not handiest limited to HTTP protocol. We can also use supported protocols like TCP, named pipes and MSMQ
No need to completely installation IIS. We can best install WAS element and preserve away the WebServer.
LINQ Interview Questions
Question 43. What Is Service Host Factory In Wcf?

Answer :

Service host manufacturing unit is the mechanism by using which we will create the instances of service host dynamically as the request comes in.
This is beneficial whilst we need to put into effect the occasion handlers for commencing and ultimate the service.
WCF offers ServiceFactory magnificence for this reason.
Question forty four. What Are The Different Platforms Where We Can Host Wcf Service ?

Answer :

WCF Services can be hosted on following platforms

WAS(Windows Activation Service)
Self Hosting
IIS
Question 45. What Are The Different Wcf Binding Available?

Answer :

BasicHttpBinding
WSHttpBinding
WSDualHttpBinding
WSFederationHttpBinding
NetTcpBinding
NetNamedPipeBinding
NetMsmqBinding
NetPeerTcpBinding
MsmqIntegrationBinding
Question 46. Advantages Of Hosting Wcf In Iis?

Answer :

Provides system activation and recycling potential thereby growing reliability
It is a simplified manner of deployment and development of hosted services.
Hosting WCF offerings in IIS can take benefit of scalability and density features of ASP.NET
Question 47. Can We Overload Methods In Wcf Service Or Web Service?

Answer :

Yes for a WCF Service use the Name property of OperationContractAttribute magnificence

example:

[ServiceContract]
interface ddd

[OperationContract(Name = "one")]
int calc(int a,int b)?
[OperationContract(Name = "two")]
double calc(double a,double b)?


For a Web Service use the MessageName assets of WebMethodAttribute magnificence
Please remark the following line in the .Cs record of the Web Service
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[WebMethod]
public string HelloWorld(string a) 
go back "Hello"+" "+a?

[WebMethod(MessageName="second")]
public string HelloWorld()

go back "Hello 2d"?


Question 48. What Does A Windows Communication Foundation, Or Wcf, Service Application Use To Present Exception Information To Clients By Default?

Answer :

However, the service can't go back a .NET exception to the client. The WCF carrier and the purchaser speak with the aid of passing SOAP messages. If an exception happens, the WCF runtime serializes the exception into XML and passes that to the patron.

Question forty nine. What Is The Use Of Is Required Property In Data Contracts?

Answer :

Data Contracts, is used to define Required or NonRequired information individuals. It may be completed with a belongings named IsRequired on DataMember attribute.

[DataContract]
public elegance check

[DataMember(IsRequired=true)]
public string NameIsMust;
[DataMember(IsRequired=false)]
public string Phone;


Question 50. What Is Data Contract Equivalence?

Answer :

Two facts contracts are said to be equal, if they fulfill the subsequent situations.

Both the datacontracts ought to have equal namespace
Both the datacontracts have to have same call
The information member on information settlement ought to have an equal information member on the opposite.
The contributors in the datacontract ought to seem in the equal order in each datacontracts.
Ex:

The following  data contracts are identical.

[DataContract]
public magnificence Person

[DataMember]
public string Name;
[DataMember]
public string Email_ID;

[DataContract(Name = "Person")]
public elegance Employee

[DataMember(Name = "Name")]
personal string EmpName;
private string deal with;
[DataMember(Name = "Email_ID")]
non-public string EmpEmailId;


Question 51. How Do We Customize Data Contract Names For Generics Types?

Answer :

We can customise the familiar datacontract names by using allowing parameters. Find the Example underneath

[DataContract(Name = "Shape_1_brush_and_0_shape")]
public magnificence Shape< Square,RedBrush>

// Code no longer proven.


Here, the Data Contract Name is "Shape_RedBrush_brush_and_Square_shape”

zero - First Parameter in the popular kind.

1 - Second Parameter within the typical kind.




CFG