Top 20 WCF Interview Questions and Answers
WCF is Microsoft's unified programming model for building service-oriented applications. It enables developers to build secure, reliable, trans
that can be integrated across platforms and interoperate with existing. This article contains the top 20 WCF interview questions and answers, in
o you for the interview.
SOA stands for Service Oriented Architecture. It is an architectural design pattern which states that every component of a system should be
service means a unit of a program that serves a business process), and the system should be composed of several loosely-coupled services
should be independent of each other, so that changing one of them should not affect any other services.
There are four Service-oriented principles (tenets) in SOA as given below :
1. Boundaries are explicit: This SOA principle states that a service can be deployed anywhere and be easily and freely accessed by
regardless of the environment or development language of the other services.
2. Services are autonomous: This SOA principle states that each service must be managed and versioned differently so that they do n
services in the process. Contracts, once published, should not be changed. Services need to be isolated and decoupled to accomplish the
them autonomous.
3. Services share schema and contract, not class: This SOA principle states that services should not pass classes and types; they pass s
and contracts (behaviors). This allows for a loosely coupled system where the service does not care what type of environment the
executing on. The information being passed is 100% platform independent.
4. Service compatibility is determined based on policy: This SOA principle states that each service should have its own compatibility level
it would interact with other services. Services look at each other’s policy, looking for similarities so that they can start communicating.
Q1. What is SOA?
Q2. What are Service Oriented Design Principles?
can’t satisfy each other’s policy requirements, they are not compatible with each other.
The differences between ASP.NET Web Service and WCF are given below:
WCF
ServiceContract and
OperationContract attributes
are used for defining WCF
service.
Supports various protocols
like HTTP, HTTPS, TCP,
Named Pipes and MSMQ.
Hosted in IIS, WAS (Windows
Activation Service), Self-
hosting, Windows Service.
Supports security, reliable
messaging, transaction and
AJAX and REST supports.
Supports DataContract
serializer by using
System.Runtime.Serialization.
Supports One-Way, Request-
Response, and Duplex service
operations.
ASP.NET Web Service
WebService and WebMethod attributes are used for defining web service.
Supports only HTTP, HTTPS protocols.
Hosted only in IIS.
Support security but is less secure as compared to WCF.
Supports XML serializer by using System.Xml.Serialization.
Supports One-Way and Request-Response service operations.
SOAP stands for Simple Object Access Protocol which is used for exchanging data in XML-based format over HTTP. SOAP is widely-used b
for exchanging data. A simple SOAP message structure is given below:
<soap:Envelope xmlns:soap=”http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/so
<soap:Body xmlns:m="http://www.mysite.com/books">
<m:Book>
<m:BookName>WCF and Web Services Interview Questions and Answers</m:BookName>
</m:Book>
</soap:Body>
</soap:Envelope>
The SOAP protocol is used for message exchange between Web Services. But SOAP defines very basic semantics for message headers. It d
define meaning to the header. Hence to extend SOAP, WS-* protocols specifications have been developed with semantics which can the
various application scenarios.
WS -* protocols are a set of protocols (means standards and specifications) that helps us to implement certain needs and behaviors of a
protocols describe how to exchange messages in a secure, transactional, and reliable way by using the headers in the SOAP message. WCF
the WS -* protocols by using WsHttpBinding. This binding makes use of some of the WS -* protocols and adds the needed behaviors, such a
message calls, reliability, discovery, and addressing.
A SOAP message has an optional header and a required body element. A SOAP message header can contain the application-specific i
authentication or authorization etc. Also, a SOAP message header must be the first child element of the SOAP Envelope element. The
SOA contains the actual SOAP message. Moreover, SOAP is a combination of HTTP protocol and XML i.e. SOAP = HTTP + XML
Q3. What is SOAP?
Q4. What is WS -* Protocols?
Q5. What are the differences between ASP.NET Web Service and WCF?
Others sample Addresses are given below:
WCF ABC stands for Address, Binding, and Contract.
A WCF service configuration with multiple endpoints is given below :
<system.serviceModel>
<services >
<service name = "MyWCFService">
WCF Address specifies to a specific location, where the service is hosted. A WCF Address is specified as a URI. URI’s first part specifie
protocol (HTTP, TCP, Net.pipe and MSMQ), and the other parts specify the host machine address and service path as shown in below fig.
WCF contract specifies what the service contains. WCF has five types of contracts: service contract, operation contract, data contract, me
and fault contract. Each contract defines certain behavior.
WCF is faster than Web
Services.
HashTable can be serialized.
Unhandled Exceptions does
not return to the client as
SOAP faults. WCF supports
better exception handling by
using FaultContract.
Supports XML, MTOM, Binary
message encoding.
Supports multi-threading by
using ServiceBehaviour class.
Web Services are slower than WCF
HashTable cannot be serialized. It can serialize only those collections which implement IEnumerable and ICo
Unhandled Exceptions returns to the client as SOAP faults.
Supports XML and MTOM (Message Transmission Optimization Mechanism) message encoding.
Doesn’t support multi-threading.
WCF binding specifies how the service and client will communicate with each other in terms of transport protocols and encoding (such as
WCF binding is a set of binding elements and each element specify, how the service and client will communicate with each other. Each bindin
least one transport element and one message encoding element.
WCF is a programming model for building and developing the service-oriented application. WCF allows applications to communicate with
distributed environment. WCF is a set of technologies that covers ASMX web services, Web Services Enhancements (WSE), .NET Remoting a
purpose of WCF is to provide a single programming model that can be used to create services on the .NET platform for organizations.
Q6. What is WCF?
Q7. What is WCF ABC?
Q8. How to define multiple endpoints for a WCF service?
Binding (How)
Contract (What)
Address (Where)
http://www.mywebsite/MyService
net.tcp://www.mywebsite/MyService
net.pipe://www.mywebsite/MyPipeService
net.msmq://www.mywebsite/MyMsMqServic
e
<endpoint address = "http://localhost:90/MyWCFService"
binding = "wsHttpBinding" contract = "IMyWCFContract"/>
<endpoint address = "net.tcp://localhost:91/MyWCFService"
binding = "netTcpBinding" contract = "IMyWCFContract"/>
</service>
</services>
</system.serviceModel>
Q9. What are default Endpoints?
WCF offers some default endpoints to the service if a service host doesn’t define any endpoints but has at least one base address. For exam
the basic binding for the Http address.
Q13. What is Binding?
Q10. What are standard Endpoints?
WCF provides a set of pre-defined endpoints known as Standard Endpoints for metadata exchange, discovery and web. You can configu
endpoints by using a config file and programmatically. Here is the list of standard endpoints :
Q11. What are the different WCF contracts?
WCF contract specifies the service and its operations. WCF has five types of contracts:
Q12. What are the various ways of hosting a WCF service?
There are four ways of hosting a WCF service.
Self-Hosting
Windows services hosting
IIS hosting
Windows Activation Services hosting (WAS)
1. Service contract
2. Operation contract
3. Data contract
4. Message contract
5. Fault contract.
mexEndpoint
webHttpEndpoint
webScriptEndpoint
workflowControlEndpoint
announcementEndpoint
discoveryEndpoint
udpAnnouncementEndpoint
udpDiscoveryEndpoint
WCF supports the following types of built-in bindings:
1. Basic binding
2. Web binding
3. Web Service (WS) binding
4. WS Dual binding
5. TCP binding
. IPC binding
7. MSMQ binding
. Federated WS binding
9. Peer Network binding
10. MSMQ integration binding
There are two ways to create a WCF Client or calling a WCF Service as:
WCF Proxy
Channel factory
WCF manages the session by creating the instance of the service class. This created instance(s) handle the incoming service request. In WC
the way of managing the services instance(s) so that the server can use these instances in an optimized way. At the server side, the Instance
used to manage service class instance. There are following instance management ways :
Per Call
Per Session
Single
Concurrency management is closely related to the Instance management in WCF but both are two different things. Instance management sp
service instances are created while Concurrency management specifies how many concurrent requests are handled by the service insta
concurrency, you can make your service instance thread-safe. By default, a per-call service instance is thread-safe since each request is s
service instance. A per-session service instance is not thread-safe since multiple requests of a client are served by a single service insta
required concurrency management. A single service instance is not thread-safe since multiple requests of all clients are served by a single s
Hence, it’s required concurrency management.
Impersonation is a way to authorize a caller (client) identity to access the service domain’s resources. The service resources may be local fi
tables and should be on the same machine on which service is hosted. By default, impersonation is disabled and resources are accessed by
WCF binding specifies how the service and client will communicate with each other in terms of transport protocols and encoding (such as
WCF binding is a set of binding elements and each element specify, how the service and client will communicate with each other. Each bindin
least one transport element and one message encoding element.
Q18. What is Impersonation?
Q16. What is Instance Management in WCF?
Q15. What are the ways to create a WCF Client?
Q17. What is Concurrency Management in WCF?
Q14. What are the different types of bindings in WCF?
service's process identity.
I hope these questions and answers will help you to crack your WCF interview. These interview Questions
have been taken from our new released eBook WCF/Web Services Interview Questions & Answers. This
book contains more than 110+ WCF interview questions.
This eBook has been written to make you confident in WCF with a solid foundation. Also, this will help you
to turn your programming into your profession. It's would be equally helpful in your real projects or to
crack your WCF Interview.
WCF Data Services uses OData (Open Data Protocol) protocol for querying or manipulating the data. WCF Data Services is built on top
Services. It is a RESTful service to support CRUD operations on the database using the HTTP protocol. It supports all database operations u
protocol can expose data from the relational database, File systems, Web sites, services etc. It supports XML or JSON format for exposing th
After the initial deployment of the WCF service, you may need to change the service for a variety of reasons like as changing business needs
issues. Each change in your existing service introduces a new version of the service. Service versioning is helpful in backward compat
existing clients.
Q20. What is WCF Data Service?
Q19. What is service versioning?
Summary
Buy this eBook at a Discounted Price!

WCF Interview Questions By Scholarhat PDF

  • 1.
    Top 20 WCFInterview Questions and Answers WCF is Microsoft's unified programming model for building service-oriented applications. It enables developers to build secure, reliable, trans that can be integrated across platforms and interoperate with existing. This article contains the top 20 WCF interview questions and answers, in o you for the interview. SOA stands for Service Oriented Architecture. It is an architectural design pattern which states that every component of a system should be service means a unit of a program that serves a business process), and the system should be composed of several loosely-coupled services should be independent of each other, so that changing one of them should not affect any other services. There are four Service-oriented principles (tenets) in SOA as given below : 1. Boundaries are explicit: This SOA principle states that a service can be deployed anywhere and be easily and freely accessed by regardless of the environment or development language of the other services. 2. Services are autonomous: This SOA principle states that each service must be managed and versioned differently so that they do n services in the process. Contracts, once published, should not be changed. Services need to be isolated and decoupled to accomplish the them autonomous. 3. Services share schema and contract, not class: This SOA principle states that services should not pass classes and types; they pass s and contracts (behaviors). This allows for a loosely coupled system where the service does not care what type of environment the executing on. The information being passed is 100% platform independent. 4. Service compatibility is determined based on policy: This SOA principle states that each service should have its own compatibility level it would interact with other services. Services look at each other’s policy, looking for similarities so that they can start communicating. Q1. What is SOA? Q2. What are Service Oriented Design Principles?
  • 2.
    can’t satisfy eachother’s policy requirements, they are not compatible with each other. The differences between ASP.NET Web Service and WCF are given below: WCF ServiceContract and OperationContract attributes are used for defining WCF service. Supports various protocols like HTTP, HTTPS, TCP, Named Pipes and MSMQ. Hosted in IIS, WAS (Windows Activation Service), Self- hosting, Windows Service. Supports security, reliable messaging, transaction and AJAX and REST supports. Supports DataContract serializer by using System.Runtime.Serialization. Supports One-Way, Request- Response, and Duplex service operations. ASP.NET Web Service WebService and WebMethod attributes are used for defining web service. Supports only HTTP, HTTPS protocols. Hosted only in IIS. Support security but is less secure as compared to WCF. Supports XML serializer by using System.Xml.Serialization. Supports One-Way and Request-Response service operations. SOAP stands for Simple Object Access Protocol which is used for exchanging data in XML-based format over HTTP. SOAP is widely-used b for exchanging data. A simple SOAP message structure is given below: <soap:Envelope xmlns:soap=”http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/so <soap:Body xmlns:m="http://www.mysite.com/books"> <m:Book> <m:BookName>WCF and Web Services Interview Questions and Answers</m:BookName> </m:Book> </soap:Body> </soap:Envelope> The SOAP protocol is used for message exchange between Web Services. But SOAP defines very basic semantics for message headers. It d define meaning to the header. Hence to extend SOAP, WS-* protocols specifications have been developed with semantics which can the various application scenarios. WS -* protocols are a set of protocols (means standards and specifications) that helps us to implement certain needs and behaviors of a protocols describe how to exchange messages in a secure, transactional, and reliable way by using the headers in the SOAP message. WCF the WS -* protocols by using WsHttpBinding. This binding makes use of some of the WS -* protocols and adds the needed behaviors, such a message calls, reliability, discovery, and addressing. A SOAP message has an optional header and a required body element. A SOAP message header can contain the application-specific i authentication or authorization etc. Also, a SOAP message header must be the first child element of the SOAP Envelope element. The SOA contains the actual SOAP message. Moreover, SOAP is a combination of HTTP protocol and XML i.e. SOAP = HTTP + XML Q3. What is SOAP? Q4. What is WS -* Protocols? Q5. What are the differences between ASP.NET Web Service and WCF?
  • 3.
    Others sample Addressesare given below: WCF ABC stands for Address, Binding, and Contract. A WCF service configuration with multiple endpoints is given below : <system.serviceModel> <services > <service name = "MyWCFService"> WCF Address specifies to a specific location, where the service is hosted. A WCF Address is specified as a URI. URI’s first part specifie protocol (HTTP, TCP, Net.pipe and MSMQ), and the other parts specify the host machine address and service path as shown in below fig. WCF contract specifies what the service contains. WCF has five types of contracts: service contract, operation contract, data contract, me and fault contract. Each contract defines certain behavior. WCF is faster than Web Services. HashTable can be serialized. Unhandled Exceptions does not return to the client as SOAP faults. WCF supports better exception handling by using FaultContract. Supports XML, MTOM, Binary message encoding. Supports multi-threading by using ServiceBehaviour class. Web Services are slower than WCF HashTable cannot be serialized. It can serialize only those collections which implement IEnumerable and ICo Unhandled Exceptions returns to the client as SOAP faults. Supports XML and MTOM (Message Transmission Optimization Mechanism) message encoding. Doesn’t support multi-threading. WCF binding specifies how the service and client will communicate with each other in terms of transport protocols and encoding (such as WCF binding is a set of binding elements and each element specify, how the service and client will communicate with each other. Each bindin least one transport element and one message encoding element. WCF is a programming model for building and developing the service-oriented application. WCF allows applications to communicate with distributed environment. WCF is a set of technologies that covers ASMX web services, Web Services Enhancements (WSE), .NET Remoting a purpose of WCF is to provide a single programming model that can be used to create services on the .NET platform for organizations. Q6. What is WCF? Q7. What is WCF ABC? Q8. How to define multiple endpoints for a WCF service? Binding (How) Contract (What) Address (Where) http://www.mywebsite/MyService net.tcp://www.mywebsite/MyService net.pipe://www.mywebsite/MyPipeService net.msmq://www.mywebsite/MyMsMqServic e
  • 4.
    <endpoint address ="http://localhost:90/MyWCFService" binding = "wsHttpBinding" contract = "IMyWCFContract"/> <endpoint address = "net.tcp://localhost:91/MyWCFService" binding = "netTcpBinding" contract = "IMyWCFContract"/> </service> </services> </system.serviceModel> Q9. What are default Endpoints? WCF offers some default endpoints to the service if a service host doesn’t define any endpoints but has at least one base address. For exam the basic binding for the Http address. Q13. What is Binding? Q10. What are standard Endpoints? WCF provides a set of pre-defined endpoints known as Standard Endpoints for metadata exchange, discovery and web. You can configu endpoints by using a config file and programmatically. Here is the list of standard endpoints : Q11. What are the different WCF contracts? WCF contract specifies the service and its operations. WCF has five types of contracts: Q12. What are the various ways of hosting a WCF service? There are four ways of hosting a WCF service. Self-Hosting Windows services hosting IIS hosting Windows Activation Services hosting (WAS) 1. Service contract 2. Operation contract 3. Data contract 4. Message contract 5. Fault contract. mexEndpoint webHttpEndpoint webScriptEndpoint workflowControlEndpoint announcementEndpoint discoveryEndpoint udpAnnouncementEndpoint udpDiscoveryEndpoint
  • 5.
    WCF supports thefollowing types of built-in bindings: 1. Basic binding 2. Web binding 3. Web Service (WS) binding 4. WS Dual binding 5. TCP binding . IPC binding 7. MSMQ binding . Federated WS binding 9. Peer Network binding 10. MSMQ integration binding There are two ways to create a WCF Client or calling a WCF Service as: WCF Proxy Channel factory WCF manages the session by creating the instance of the service class. This created instance(s) handle the incoming service request. In WC the way of managing the services instance(s) so that the server can use these instances in an optimized way. At the server side, the Instance used to manage service class instance. There are following instance management ways : Per Call Per Session Single Concurrency management is closely related to the Instance management in WCF but both are two different things. Instance management sp service instances are created while Concurrency management specifies how many concurrent requests are handled by the service insta concurrency, you can make your service instance thread-safe. By default, a per-call service instance is thread-safe since each request is s service instance. A per-session service instance is not thread-safe since multiple requests of a client are served by a single service insta required concurrency management. A single service instance is not thread-safe since multiple requests of all clients are served by a single s Hence, it’s required concurrency management. Impersonation is a way to authorize a caller (client) identity to access the service domain’s resources. The service resources may be local fi tables and should be on the same machine on which service is hosted. By default, impersonation is disabled and resources are accessed by WCF binding specifies how the service and client will communicate with each other in terms of transport protocols and encoding (such as WCF binding is a set of binding elements and each element specify, how the service and client will communicate with each other. Each bindin least one transport element and one message encoding element. Q18. What is Impersonation? Q16. What is Instance Management in WCF? Q15. What are the ways to create a WCF Client? Q17. What is Concurrency Management in WCF? Q14. What are the different types of bindings in WCF?
  • 6.
    service's process identity. Ihope these questions and answers will help you to crack your WCF interview. These interview Questions have been taken from our new released eBook WCF/Web Services Interview Questions & Answers. This book contains more than 110+ WCF interview questions. This eBook has been written to make you confident in WCF with a solid foundation. Also, this will help you to turn your programming into your profession. It's would be equally helpful in your real projects or to crack your WCF Interview. WCF Data Services uses OData (Open Data Protocol) protocol for querying or manipulating the data. WCF Data Services is built on top Services. It is a RESTful service to support CRUD operations on the database using the HTTP protocol. It supports all database operations u protocol can expose data from the relational database, File systems, Web sites, services etc. It supports XML or JSON format for exposing th After the initial deployment of the WCF service, you may need to change the service for a variety of reasons like as changing business needs issues. Each change in your existing service introduces a new version of the service. Service versioning is helpful in backward compat existing clients. Q20. What is WCF Data Service? Q19. What is service versioning? Summary Buy this eBook at a Discounted Price!