8/10/2019 WCF Interview Qns.doc
1/68
WCF Interview Questions
1) What is service host factory in WCF?
1. Service host factory is the mechanism by which we can create the instances of
service host dynamically as the request comes in.
2. This is useful when we need to implement the event handlers for opening andclosing the service.
3. WC provides Serviceactory class for this purpose.
2) What are tha advantages of hosting WCF service in WAS?
W!S "Windows !ctivation Service# is a component of $$S %.&. ollowing are few
advantages '
1. We are not only limited to (TT) protocol. We can also use supported protocols li*eTC)+ named pipes and ,S,-
2. o need to completely install $$S. We can only install W!S component and *eep
away the WebServer.
3) In WCF which bindings suorts the re!iab!e session?
$n WC+ following bindings supports the reliable session
1. ws(ttp/inding
2. ws0ual(ttp/inding3. wsederation(ttp/inding. netTcp/inding
") What is Address #eader in WCF?
!ddress (eader contains the information which is sent with every request+ it can be
used by either end point service or any intermediate device for determining anyrouting logic or processing logic.
WC provides !ddress(eader class for this purpose.
ample '
!ddress(eader address(eader4 !ddress(eader.Create!ddress(eader"5ame of the
header5+ 5$nformation included in header 5#6
7nce the !ddress(eader instance is created+ it can be associated with end point
instance as follows '
http://www.dotnetfunda.com/interview/exam3134-what-is-service-host-factory-in-wcf-.aspxhttp://www.dotnetfunda.com/interview/exam3133-what-are-tha-advantages-of-hosting-wcf-service-in-was-.aspxhttp://www.dotnetfunda.com/interview/exam3132-in-wcf-which-bindings-supports-the-reliable-session-.aspxhttp://www.dotnetfunda.com/interview/exam3131-what-is-address-header-in-wcf-.aspxhttp://www.dotnetfunda.com/interview/exam3134-what-is-service-host-factory-in-wcf-.aspxhttp://www.dotnetfunda.com/interview/exam3133-what-are-tha-advantages-of-hosting-wcf-service-in-was-.aspxhttp://www.dotnetfunda.com/interview/exam3132-in-wcf-which-bindings-supports-the-reliable-session-.aspxhttp://www.dotnetfunda.com/interview/exam3131-what-is-address-header-in-wcf-.aspx8/10/2019 WCF Interview Qns.doc
2/68
ndpoint!ddress endpoint 4 new ndpoint!ddress"new8ri"5http'99myserver9myservice5#+ address(eader#6
$) #ow to set the instancing %ode in WCF service?
$n WC+ instancing mode is set at service level. or e.
99Setting )erSession instance mode
:Service/ehavior"$nstanceContet,ode 4 $nstanceContet,ode.)erSession#;
class ,yService ' $,yServiceor ways of hosting a WC services
Q Self@hosting the service in his own application domain. This we have already
covered in the first section. The service comes in to eistence when you create the
ob>ect of Service (ost class and the service closes when you call the Close of theService (ost class.
Q (ost in application domain or process provided by $$S Server.
Q (ost in !pplication domain and process provided by W!S "Windows !ctivation
Service# Server.
,ore detailshttp'99www.dotnetfunda.com9articles9article221.aspIwhatarethevariouswaysofhosti
ngaWCservice
3") What are the %ain co%onents of WCF?
The main components of WC are
1. Service class
2. (osting environment3. nd point
http://www.dotnetfunda.com/interview/exam542-what-is-the-difference-wcf-and-web-services-.aspxhttp://msdn.microsoft.com/en-us/library/aa738737.aspxhttp://www.dotnetfunda.com/interview/exam541-what-are-various-ways-of-hosting-wcf-services-.aspxhttp://www.dotnetfunda.com/articles/article221.aspx#whatarethevariouswaysofhostingaWCFservicehttp://www.dotnetfunda.com/articles/article221.aspx#whatarethevariouswaysofhostingaWCFservicehttp://www.dotnetfunda.com/interview/exam540-what-are-the-main-components-of-wcf-.aspxhttp://www.dotnetfunda.com/interview/exam542-what-is-the-difference-wcf-and-web-services-.aspxhttp://msdn.microsoft.com/en-us/library/aa738737.aspxhttp://www.dotnetfunda.com/interview/exam541-what-are-various-ways-of-hosting-wcf-services-.aspxhttp://www.dotnetfunda.com/articles/article221.aspx#whatarethevariouswaysofhostingaWCFservicehttp://www.dotnetfunda.com/articles/article221.aspx#whatarethevariouswaysofhostingaWCFservicehttp://www.dotnetfunda.com/interview/exam540-what-are-the-main-components-of-wcf-.aspx8/10/2019 WCF Interview Qns.doc
9/68
or more details readhttp'99www.dotnetfunda.com9articles9article221.aspIWhatarethemaincomponentsof
WC
3$) What was the code na%e for WCF?
The code name of WC was $ndigo .
WC is a unification of .T framewor* communication technologies which unites the
following technologies'@
T remoting
,S,-Web services
C7,R
3&) #ow to dea! with oeration over!oading whi!e e5osing the WCF
services?
/y default overload operations "methods# are not supported in WS0? based
operation. (owever by using ame property of 7perationContract attribute+ we candeal with operation overloading scenario.
:ServiceContract;interface $Calculator
ects are serialiFedor deserialiFed. WC always serialiFes and de@
serialiFes information during request so itXs agood event to see the content of the request.
System.$7.?ogmits messages with respect to Common ?og
ile System "C?S#.
CardSpace
mits trace messages related to any
CardSpace identity processing that occurswithin WC contet.
# Can you eplain the concept of trace listener
TracelistenerX are ob>ects that get tracing information from the trace class and they
output the data to some medium. or instance you can see from the figureTrace?istenerX how it listens to the trace ob>ect and outputs the same to 8$+ ile or a
windows event log. There are three different types of tracelistenerX first is thedefaulttracelistenerX "this outputs the data to 8$#+ second is tetwritertracelistenerX
"this outputs to a file# and the final one is ventlogtracelistenerX which outputs thesame to a windows event log.
http://www.dotnetfunda.com/interview/exclusive/x786-can-you-explain-the-concept-of-trace-listener-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x786-can-you-explain-the-concept-of-trace-listener-.aspx8/10/2019 WCF Interview Qns.doc
21/68
igure \ Trace?istener
/elow is a code snippet for tetwritertracelistenerX and eventlogtracelistenerX. 8singtetwritertracelistenerX we have forwarded the traceXs to rror?og.ttX file and in the
second snippet we have used the ventlogtracelistenerX to forward the traceXs towindows event log.
igure'@ Tracelistener in action
E# Can you show the security differences between /asic(ttp/inding JS
Ws(ttp/inding
$n order to understand the security differences between both these entities we will
do a small pro>ect. $n this pro>ect we will create two WC service one service using/asic(ttp/indingX and the second service using Ws(ttp/indingX.
http://www.dotnetfunda.com/interview/exclusive/x785-can-you-show-the-security-differences-between-basichttpbinding-vs-wshttpbin-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x785-can-you-show-the-security-differences-between-basichttpbinding-vs-wshttpbin-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x785-can-you-show-the-security-differences-between-basichttpbinding-vs-wshttpbin-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x785-can-you-show-the-security-differences-between-basichttpbinding-vs-wshttpbin-.aspx8/10/2019 WCF Interview Qns.doc
22/68
Ste1=,So letXs first create a simple service using /asic(ttp/indingX. or that we
>ust a create a simple WC pro>ect and then modify the Service,odelX element asshown below. Vou can see in the endpointX tag we have specified basic(ttp/indingX
as the protocol.
Bsystem.service,odelBservices
Bservice name45WC/asic(ttp/inding.Service15behaviorConfiguration45WC/asic(ttp/inding.Service1/ehavior5
B]@@ Service ndpoints @@Bendpoint address455 binding45basic(ttp/inding5
contract45WC/asic(ttp/inding.$Service15B]^
8pon deployment+ the following identity element should be removed or replaced toreflect the
identity under which the deployed service runs. $f removed+ WC will infer anappropriate identity
automatically.
@@Bidentity
Bdns value45localhost59
B9identityB9endpoint
Bendpoint address45me5 binding45me(ttp/inding5contract45$,etadatachange59
B9serviceB9services
Bbehaviors
Bservice/ehaviorsBbehavior name45WC/asic(ttp/inding.Service1/ehavior5B]@@ To avoid disclosing metadata information+ set the value below to false and
remove the metadata endpoint above before deployment @@
Bservice,etadata httpOetnabled45true59B]@@ To receive eception details in faults for debugging purposes+ set the value
below to true. Set to false before deployment to avoid disclosing eception
8/10/2019 WCF Interview Qns.doc
23/68
information @@Bservice0ebug includeception0etail$naults45false59
B9behaviorB9service/ehaviors
B9behaviorsB9system.service,odel
Ste 2 =,We also need to create one more service using Ws(ttp/indingX. or thatyou do not need to anything special as such. /y default WC pro>ect is created using
Ws(ttp/indingX. /elow is how the Web.config file loo*s li*e. Vou can see how theendpoint tag is using ws(ttp/indingX.
Bsystem.service,odelBservices
Bservice name45WCWs(ttp/inding(ttps.Service15behaviorConfiguration45WCWs(ttp/inding(ttps.Service1/ehavior5
B]@@ Service ndpoints @@Bendpoint address455 binding45ws(ttp/inding5
contract45WCWs(ttp/inding(ttps.$Service15B]@@
8pon deployment+ the following identity element should be removed or replaced toreflect the
identity under which the deployed service runs. $f removed+ WC will infer anappropriate identity
automatically.@@
BidentityBdns value45localhost59
B9identityB9endpoint
Bendpoint address45me5 binding45me(ttp/inding5
contract45$,etadatachange59B9serviceB9services
BbehaviorsBservice/ehaviors
Bbehavior name45WCWs(ttp/inding(ttps.Service1/ehavior5
B]@@ To avoid disclosing metadata information+ set the value below to false andremove the metadata endpoint above before deployment @@
Bservice,etadata httpOetnabled45true59
B]@@ To receive eception details in faults for debugging purposes+ set the valuebelow to true. Set to false before deployment to avoid disclosing eception
information @@Bservice0ebug includeception0etail$naults45false59
B9behaviorB9service/ehaviors
B9behaviorsB9system.service,odel
8/10/2019 WCF Interview Qns.doc
24/68
Ste 3 =,We will not be creating any new methods in both the services. We will >ustuse the default code created by the WC template. So both these services will have a
Oet0ataX function which returns a string. The Oet0ataX function is a default functioncreated WC pro>ect.
public class Service1 ' $Service1
.Credentials 4 System.et.CredentialCache.0efaultCredentials6
ow if you eecute you should get the below error stating that this is a unauthoriFed
call.
Source Code
Whatever code we have discussed in the above !- . Vou can download the Source
Code from here
$() #ow can we enab!e windows authentication on WCF using
>+asic#tt+inding? art,1
Ste 1=,Create a pro>ect of WC service application as shown in the below figure.
http://www.dotnetfunda.com/interview/exclusive/x783-how-can-we-enable-windows-authentication-on-wcf-using-%E2%80%98basichttpbinding-p-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x783-how-can-we-enable-windows-authentication-on-wcf-using-%E2%80%98basichttpbinding-p-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x783-how-can-we-enable-windows-authentication-on-wcf-using-%E2%80%98basichttpbinding-p-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x783-how-can-we-enable-windows-authentication-on-wcf-using-%E2%80%98basichttpbinding-p-.aspx8/10/2019 WCF Interview Qns.doc
30/68
Circle WC service application Select this
/y default the WC pro>ect creates a class file which has Oet0ataX function. Thisfunction ta*es in a number values and displays a eplanatory sentence li*e Vou
entered 1 valueX + in case you have entered 1X.
public class Service1 ' $Service1
Connection#6
ob>Command.ecuteon-uery"#6
http://www.dotnetfunda.com/interview/exclusive/x776-can-we-see-simple-wcf-example-of-transactions-using-sql-server-database-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x776-can-we-see-simple-wcf-example-of-transactions-using-sql-server-database-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x776-can-we-see-simple-wcf-example-of-transactions-using-sql-server-database-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x776-can-we-see-simple-wcf-example-of-transactions-using-sql-server-database-.aspx8/10/2019 WCF Interview Qns.doc
40/68
ob>Connection.Close"#6=
Ste "=,nable transaction flow using WC service config file
We also need to enable transactions for ws(ttp/indingX by setting thetransactionlowX attribute to true.
BbindingsBws(ttp/inding
Bbinding name45Transactional/ind5 transactionlow45true59B9ws(ttp/inding
B9bindings
The transaction enabled binding we need to attach with the end point through which
our WC service is eposed.
Bendpoint address455 binding45ws(ttp/inding5bindingConfiguration45Transactional/ind5 contract45WcfService1.$Service15
Ste $=,Call the 2 services in one transaction
ow that we are done with our server side transaction enablement+ itXs time to call
the above 2 services in 1 transaction. We need to use the TransactionScopeX ob>ectto group the above 2 WC services in one transaction. To commit all the WC
transactions we call the CompleteX method of the TransactionscopeX ob>ect. Torollbac* we need to call the 0isposeX method.
using "TransactionScope ts 4 newTransactionScope"TransactionScope7ption.Aequiresew##
.8pdate0ata"#6ServiceAeference2.Service1Client ob>1 4 new ServiceAeference2.Service1Client"#6
ob>1.8pdate0ata"#6ts.Complete"#6
=catch "ception e#
ects if the 8A$. Vou can also give the 8A$ through config file. )ass these twoob>ects of the 8A$ in the constructor parameter when creating the service host
ob>ect.
igure 2&'@ Server side code for ,ulti )rotocol hosting3 \ $n the config file we need to define two bindings and end as we are hosting the
service in multiple protocols.7nce we are done the server side coding its time to see ma*e a client by which we
can switch between the protocols and see the results. /elow is the code snippet ofthe client side for multi@protocol hosting.
8/10/2019 WCF Interview Qns.doc
55/68
Figure 21=, .u!ti rotoco! C!ient code
/et us understand the code=,1 @ $n the generated config file we have added two ends. When we generate the
config file+ it generates only for one protocol. The other end has to be manuallyadded.
2 @ To test the same we have a list bo+ which has the name value given in the endpoint.
3 @ $n the list bo select event we have then loaded the selected protocol. The
selected protocol string needs to be given in the proy class and finally call the proyclass OetTotalCost.
'') Can you e5!ain du!e5 contracts in WCF?
$n duple contracts when client initiates an operation the server service provides areference call bac* 8ri bac* to the client. So the client initiates a call using the proy
class and when server finishes its wor* it notifies the client using the callbac*channel. This is called as duple messaging in WC. $f you remember in the previous
http://www.dotnetfunda.com/interview/exclusive/x757-can-you-explain-duplex-contracts-in-wcf-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x757-can-you-explain-duplex-contracts-in-wcf-.aspx8/10/2019 WCF Interview Qns.doc
56/68
question+ we had no way to *now when the server finished its tas*.
igure 1P'@ 0uple Service code
8/10/2019 WCF Interview Qns.doc
57/68
?et us try to understand the duple concept by doing a small sample. The code
snippet is as shown in the above figure. We will etend the previous sample+ whichwas shown in the first question only that now we will provide the notification to the
client once the do(ugeTas* is completed.The first step is to change the service class. !bove is the code snippet of the service
class. !gain+ we have numbered them so that we can understand how to implementit practically line by line. So below is the eplanation number by number'@
1 @ $n the service contract attribute we need to specify the callbac* contractattribute. This Callbac* Contract attribute will have the interface+ which will define
the callbac*.2 @ This is the interface which client will call. $n order that it should be asynchronous+
we have defined the one@way attribute on the do(ugeTas* method.3 @This is the most important interface. !s it forms the bridge of communication
between server and client. The server will call the client using Completed method.Client needs to provide implementation for the completed method at the client side
and server will call that method once it completes the do(ugeTas* method.
and @ $n this we implement the $nterface 0uple interface and provideimplementation for do(ugeTas* "# method.
E @ This is an important step. The 7perationContet.Current.OetCall/ac*Channel willbe used to ma*e callbac* to the client.% @ We will epose the service using (TT) protocol. $n this sample+ because we want
to do duple communication we need to use ws0ual(ttp/inding rather than >ustusing simple (ttp /inding. This new binding configuration is then assigned to the end
on which the service is hosted.This completes the server side eplanation for duple.
8/10/2019 WCF Interview Qns.doc
58/68
igure' @ 1U 0uple Client side code
!bove is the code snippet for client side. So let us eplain the above code withnumbers.
1@ We implement the completed method. This is the callbac* method+ which theserver will call when do(ugeTas* is completed.
2@ $n this step we create ob>ect of the $nstance Contet class. $nstance Contetrepresents contet information of a service. The main use of $nstance Contet is to
handle incoming messages. $n short+ proy is used to send messages to server and$nstance Contet is used to accept incoming messages.
3 @$n this step we pass the $nstance Contet ob>ect to the constructor of the proy.This is needed+ as the server will use the same channel to communicate to the client.
@ $n this section two windows are shown. The top windows is the servers outputand the below windows is of the client. Vou can see in the below window that server
as made a callbac* to the client.
ote' @ Vou can get source code for the same in WC0uple folder. eel ree to
eperiment with it. Try ma*ing one simple pro>ect of client to client chat using WCduple fundamentals $ am sure your doubts will be cleared in and out.
'() What is one,way oeration?
$s7neWay equal to true ensures that the client does not have to wait for the
response. So methods mar*ed by $s7neWay to true should always return void. $n
http://www.dotnetfunda.com/interview/exclusive/x756-what-is-oneway-operation-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x756-what-is-oneway-operation-.aspx8/10/2019 WCF Interview Qns.doc
59/68
this+ the caller does not get anything in return so it is called as one@waycommunication.
$n order to understand one@way implementation in WC lets ma*e a codewal*through of a sample.
ote' @ Vou can find code for the same in WC$s7neWayD folder in C0.
Figure 1'= , 9ne,Way in action
!bove is the code snippet+ which describes practically how one way wor*s in WC.The above given code snippet is numbered. /elow is the eplanation according to the
numbers mar*ed in figure'@1 @ This is the code snippet of the server service. We have created a method called
as do(ugeTas*. 0o(ugeTas* ma*es the method sleep for &&& ,S and then displaysthe time when the tas* is completed.
2 @ This code snippet is for client. $t creates a proy ob>ect of service$s7neWay andcalls the do(ugeTas* method. !fter calling the do(ugeTas*+ the client eecution
8/10/2019 WCF Interview Qns.doc
60/68
continues ahead. So as a proof+ we display the time when the method calling wascompleted.
3 @ This screen shot shows the output given by both server and client. The topwindow displays the server output and the below windows displays the client output.
ote= ,Vou can find the code for the same in WC$s7neWay folder. or generating
the proies you have to follow the same steps which are shown in the previous steps.
So run the server program first i.e. Service$s7neWay and run the client later. Vou will
see the client runs the do(ugeTas* and moves ahead. Therefore+ the clientcompletion time is less than the server is. 7ne more thing to understand is that one
way does not give any notification bac* of completion. Therefore+ it is li*e fire and
forgets.
') what are the advantages of hosting WCF Services in IIS as co%ared to
se!f,hosting?
8/10/2019 WCF Interview Qns.doc
61/68
Figure 1&=, IIS recyc!e otion
(*) What the different transaction otions ?
$n the previous code we have use Transactionlow7ptionX. We can specify transaction
in 3 ways in WC'@
8/10/2019 WCF Interview Qns.doc
62/68
(1) What are ead !etter 8ueues?
The main use of queue is that you do not need the client and the server running at
one time. Therefore+ it is possible that a message will lie in queue for long time untilthe server or client pic*s it up. /ut there are scenarios where a message is of no use
after a certain time. Therefore+ these *inds of messages if not delivered within that
time span it should not be sent to the user./elow is the config snippet+ which defines for how much time the message should bein queue.
Bbindings
Bnet,smq/inding
Bbinding name45,y/indings5dead?etter-ueue45Custom5
custom0ead?etter-ueue45net.msmq'99localhost9private9Service,odelSamples5timeTo?ive45&&'&&'&259
B9net,smq/inding
(2) What are @o!ati!e 8ueues?
!nswers'@ There are scenarios in the pro>ect when you want the message to deliverin proper time. The timely delivery of message is more important than losing
message. $n these scenarios+ Jolatile queues are used./elow is the code snippet+ which shows how to configure Jolatile queues. Vou can
see the binding Configuration property set to Jolatile /inding. This code will assurethat message will deliver on time but there is a possibility that you can lose data.
BappSettings
B]@@ use appSetting to configure ,S,- queue name @@
Badd *ey45queueame5 value45.Yprivate_YService,odelSamplesJolatile5 9B9appSettings
Bsystem.service,odelBservices
Bservice name45Samples.Stoc*Tic*erServ5behaviorConfiguration45CalculatorService/ehavior5...
B]@@ 0efine et,smqndpoint @@Bendpoint address45net.msmq'99localhost9private9Service,odelSamplesJolatile5
binding45net,smq/inding5bindingConfiguration45volatile/inding5
contract45Samples.$nterfaceStoc*Tic*er5 9...
B9serviceB9services
BbindingsBnet,smq/inding
Bbinding name45volatile/inding5durable45false5
eactly7nce45false59B9net,smq/inding
B9bindings...
http://www.dotnetfunda.com/interview/exclusive/x752-what-are-dead-letter-queues-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x751-what-are-volatile-queues-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x752-what-are-dead-letter-queues-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x751-what-are-volatile-queues-.aspx8/10/2019 WCF Interview Qns.doc
63/68
B9system.service,odel
(3) What are different bindings suorted by WCF?
Answer= ,
WC includes predefined bindings. They cover most of bindings widely needed inday@to@day application. (owever+ >ust incase you find that you need to define
something custom WC does not stop you. So let us try to understand what each
binding provides.
+asic#tt+inding= ,This binding is used when we need to use S7!) over (TT).
This binding can also be configured to be used as (TT)S. $t can be also configured tosend data in plain tet or in optimiFed form li*e ,T7,.
Ws#tt+inding=@ $t is same li*e /asic(ttp/inding. $n short+ it uses S7!) over
(TT). /ut with it also supports reliable message transfer+ security and transaction.
WS@Aeliable ,essaging+ security with WS@Security+ and transactions with WS@!tomicTransaction supports reliable message.
etust epose a new end. Therefore+ services are agile and which is a
very practical approach loo*ing at the current business trends.
http://www.dotnetfunda.com/interview/exclusive/x749-what-are-different-bindings-supported-by-wcf-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x748-what-are-the-major-differences-between-services-and-web-services-or-what--.aspxhttp://www.dotnetfunda.com/interview/exclusive/x748-what-are-the-major-differences-between-services-and-web-services-or-what--.aspxhttp://www.dotnetfunda.com/interview/exclusive/x749-what-are-different-bindings-supported-by-wcf-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x748-what-are-the-major-differences-between-services-and-web-services-or-what--.aspxhttp://www.dotnetfunda.com/interview/exclusive/x748-what-are-the-major-differences-between-services-and-web-services-or-what--.aspx8/10/2019 WCF Interview Qns.doc
64/68
($) What are the various ways of hosting a WCF service?
Answer= ,There are three ma>or ways to host a WC service'@
Q Self@hosting the service in his own application domain. This we have alreadycovered in the first section. The service comes in to eistence when you create the
ob>ect of Service (ost class and the service closes when you call the Close of the
Service (ost class.Q (ost in application domain or process provided by $$S Server.
Q (ost in !pplication domain and process provided by W!S "Windows !ctivation
Service# Server.
(&) What are the %ain co%onents of WCF?
Answer= ,We need to define three main components in WC'@
Q Service class.Q (osting environment
Q nd point
(') Which secifications does WCF fo!!ow?
Answer= ,
WC supports specifications defined by WS@N specifications. WS@N specifications are
defined together by ,icrosoft+ $/,+ S8 and many other big companies so that theycan epose there service through a common protocol. WC supports all specifications
defined we will understand them one by one.
Q .essaging 6WS,Addressing)=,S7!) is the fundamental protocol for webservices. WS !ddressing defines some etra additions to S7!) headers+ which ma*es
S7!) free from underlying transport protocol. 7ne of the good things about ,essagetransmission is ,T7,+ also termed as ,essage Transmission 7ptimiFation
,echanism. They optimiFe transmission format for S7!) messages in G,?@/inaryformant using G,? optimiFed pac*aging "G7)#. /ecause the data will sent in binary
and optimiFed format+ it will give us huge performance gain.
Q Security 6WS,Security7 WS,
8/10/2019 WCF Interview Qns.doc
65/68
We have stressed on the WS@N specification as it is a specification which a servicehas to follow to be compatible with other languages. /ecause WC follows WS@N
specifications other languages li*e [!J! + CRR can also eploit features li*e,essaging + Security + Aeliability and transactions written in CI or J/.T. This is the
biggest achievement of WC to integrate the above features with other languages.
ote= ,0uring interview the interviewer epects that you *now what WS@Nspecification are supported by WC and its advantages with respect to interactingwith other languages.
(() What are ends7 contracts7 address and bindings?
Answer= ,
The above terminologies are the core on which S7! stands. very service mustepose one or more ends by which the service can be available to the client. nd
consists of three important things where+ what and how'@
Q Contract 6What)
Contract is an agreement between two or more parties. $t defines the protocol howclient should communicate with your service. Technically+ it describes parameters and
return values for a method.
Q Address 6Where)!n !ddress indicates where we can find this service. !ddress is a 8A?+ which pointsto the location of the service.
Q +inding 6#ow)/indings determine how this end can be accessed. $t determines how
communications is done. or instance+ you epose your service+ which can beaccessed using S7!) over (TT) or /$!AV over TC). So for each of these
communications medium two bindings will be created./elow figure+ show the three main components of end. Vou can see the stoc* tic*er
is the service class+ which has an end hosted on www.soa.com with (TT) and TC)binding support and using Stoc* Tic*er interface type.
http://www.dotnetfunda.com/interview/exclusive/x743-what-are-ends-contracts-address-and-bindings-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x743-what-are-ends-contracts-address-and-bindings-.aspx8/10/2019 WCF Interview Qns.doc
66/68
Figure 2= , 4ndoint Architecture
ote' @ Vou can also remember the end point by !/C where ! stands for !ddress+ /for bindings and C for Contract.
() What are the i%ortant rinci!es of S9A 6Service orientedArchitecture)?
Answer= ,
WC is based on S7!. !ll big companies are playing big bets on S7!. So how can,icrosoft remain behind So in order to implement S7! architecture easily you need
to use WC.S9A is based on four i%ortant concets=,
Q +oundaries are we!! defined
$n S7!+ everything is formaliFed. The client who is consuming the service does notneed to *now how the implementation of the service is done. $f you loo* at some oldmethodologies of communication li*e 0C7,. !ny changes at server level the client
also has to change. Therefore+ the server and client implementation was so muchbound that changes need to be done at all places. $n S7!+ the rule is if you do
enhancement you do not need to change anything at the client. S7! basedapplication only understands that there is an end point+ contract+ and bindings.
ote' @ [ust to clarify shortly about end point and contract. !ny S7! service iseposed through an end point. nd point defines three important aspects What+
Where and (ow. We will understand more details of the same in the later questions.
Q Services evo!ve
Change is the law of nature and services will evolve. $n S7!+ services can be
versioned and you can host those services in new ends. or instance+ you have aservice called as Search Tic*ets "Tic*et umber# which gives details based on
Tic*et umber and its eposed on end point ep1D. Tomorrow you want ma*e yourSearch Tic*ets service more useful by also providing an etra option of allowing him
to search by passenger name. Therefore+ you >ust declare a new end ep2D withservice Search Tic*ets "Tic*et umber+ )assenger ame#D. So the client who is
consuming the service at end ep1 continues and at the other end+ we have evolved
our service by adding new ends ep2.
Q Services share on!y sche%as and contracts
Services use Schemas to represent data and contracts to understand behavior. They
do not use language dependent types or classes in order to understand data andbehavior. G,? is used to define schemas and contracts. 0ue to this+ there is not
heavy coupling between environments.
Q Service co%atibi!ity is o!icy based
http://www.dotnetfunda.com/interview/exclusive/x742-what-are-the-important-principles-of-soa-service-oriented-architecture-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x742-what-are-the-important-principles-of-soa-service-oriented-architecture-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x742-what-are-the-important-principles-of-soa-service-oriented-architecture-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x742-what-are-the-important-principles-of-soa-service-oriented-architecture-.aspx8/10/2019 WCF Interview Qns.doc
67/68
)olicy describes the capabilities of the system. 0epending on policies+ the service candegrade to match the service for the client. or instance your service needs to be
hosted for two types of client one which uses Aemoting as the communicationmethodology while other client uses 0C7,. !n ideal S7! service can cater to both of
them according to there communication policies.
ote= ,,any people assume Web services are the base for S7!. The answer is &K right. What web services lac* is the policy based Service compatibility. $f you hosta web service it can only serve with (TT) communication channel and S7!)
message. !ny other type of client trying to communicate he will not degrade it self.This is what is provided by WC. Vou can host the service in one or more mode. or
instance you can host a WC service using remoting and !S,G.
*) What is Windows Card Sace?
Answer= ,$t was previously *nown by its codename $nfo Card. $t is a framewor* by ,icrosoft+
which securely stores digital identities of a user and provides a unified interface to
choose the identity for a particular transaction+ such as logging in to a website.Windows Card Space is a central part of ,icrosoftXs effort to create an identity metsystem+ or a unified+ secure and interoperable identity layer for the internet.
1) What is 4< 3*?
$n one simple equation .T 3.& 4 .T 2.& R Windows Communication oundation
R Windows )resentation oundation R Windows Wor*flow oundation R Windows
Card Space.
2) What is WCF?
Answer= ,
irst let us give a short answer to this' @ WC "$ndigo was the code name for WC#is a unification of .T framewor* communication technologies .WC is a unification
technology+ which unites the following technologies'@Q T remoting
Q ,S,-Q Web services
Q C7,R./elow figure depicts WC fundamentals pictorially.
http://www.dotnetfunda.com/interview/exclusive/x741-what-is-windows-card-space-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x740-what-is-net-30-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x739-what-is-wcf-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x741-what-is-windows-card-space-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x740-what-is-net-30-.aspxhttp://www.dotnetfunda.com/interview/exclusive/x739-what-is-wcf-.aspx8/10/2019 WCF Interview Qns.doc
68/68
WCF Co%onents