{"id":19361407,"url":"https://github.com/kansiris/wcf-interview-questions","last_synced_at":"2026-03-19T09:27:14.679Z","repository":{"id":106185918,"uuid":"195602399","full_name":"kansiris/WCF-interview-Questions","owner":"kansiris","description":null,"archived":false,"fork":false,"pushed_at":"2019-07-12T10:32:52.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-18T03:02:29.132Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kansiris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-07T02:41:22.000Z","updated_at":"2022-04-19T17:25:02.000Z","dependencies_parsed_at":"2023-06-16T01:30:16.482Z","dependency_job_id":null,"html_url":"https://github.com/kansiris/WCF-interview-Questions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kansiris/WCF-interview-Questions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FWCF-interview-Questions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FWCF-interview-Questions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FWCF-interview-Questions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FWCF-interview-Questions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kansiris","download_url":"https://codeload.github.com/kansiris/WCF-interview-Questions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FWCF-interview-Questions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29959400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T07:22:56.498Z","updated_at":"2026-03-01T03:34:51.677Z","avatar_url":"https://github.com/kansiris.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# WCF Interview Questions \u0026 Answers\n\n\u003e Click :star:if you like the project. Pull Request are highly appreciated. Follow me [@kansiris87](https://twitter.com/kansiris87) for technical updates.\n\n### Table of Contents\n\n| No. | Questions |\n|---- | ---------\n|1    | [What is Windows Communication Foundation, WCF?](#What is Windows Communication Foundation, WCF??)|\n|2 | [What are the components of WCF?](#What are the components of WCF?)|\n|3 | [What is the difference between WCF and Web services?](#What is the difference between WCF and Web services?)|\n|4 | [What are different binding supported by WCF?](#What are different binding supported by WCF?)|\n|5 | [What is duplex contracts in WCF?](#What is duplex contracts in WCF?)|\n|6 | [How do we use MSMQ binding in WCF?](#How do we use MSMQ binding in WCF?)|\n|1    | [Explain volatile queues and Dead letter queues?](#Explain volatile queues and Dead letter queues?)|\n|2 | [What are the various ways of hosting a WCF service?](#What are the various ways of hosting a WCF service?)|\n|3 | [Explain transactions in WCF?](#Explain transactions in WCF?)|\n|4 | [What are different isolation levels provided in WCF?](#What are different isolation levels provided in WCF?)|\n|5 | [What are the advantages of hosting WCF services in IIS?\t](#What are the advantages of hosting WCF services in IIS?\t)|\n|6 | [What are the various programming approaches for WCF?](#What are the various programming approaches for WCF?)|\n|1    | [What are WCF Service Endpoints? Explain?](#What are WCF Service Endpoints? Explain?)|\n|2 | [What is DataContractSerializer and How its different from XmlSerializer?](#What is DataContractSerializer and How its different from XmlSerializer?)|\n|3 | [How we can use MessageContract partially with DataContract for a service operation in WCF?](#How we can use MessageContract partially with DataContract for a service operation in WCF?)|\n|4 | [Please explain briefly different Instance Modes in WCF?](#Please explain briefly different Instance Modes in WCF?)|\n|5 | [How can you generate proxy class and configuration file for WCF service?](#How can you generate proxy class and configuration file for WCF service?)|\n|6 | [Is there any tool provided by Microsoft for editing configutation file?](#Is there any tool provided by Microsoft for editing configutation file?)|\n|1    | [How can you test your new WCF service without writing any client application?](#How can you test your new WCF service without writing any client application?)|\n|2 | [How can you configure reliability using .config file?](#How can you configure reliability using .config file?)|\n|3 | [How can you implement operation overloading in WCF service?](#How can you implement operation overloading in WCF service?)|\n|4 | [What is Known Types?](#What is Known Types?)|\n|5 | [What is ServiceKnownType?](#What is ServiceKnownType?)|\n|6 | [What is MessageContract?](#What is MessageContract?)|\n|1    | [How is the service instance created? How can you manage or control WCF service instance creation?](#How is the service instance created? How can you manage or control WCF service instance creation?)|\n|2 | [ Can you control when the service instance is recycled?](# Can you control when the service instance is recycled?)|\n|3 | [Can you limit how many instances or sessions are created at the application level?](#Can you limit how many instances or sessions are created at the application level?)|\n|4 | [What are session modes in WCF ? How can you make a service as sessionful?](#What are session modes in WCF ? How can you make a service as sessionful?)|\n|5 | [What is MEP (Message Exception Pattern) in WCF?](#What is MEP (Message Exception Pattern) in WCF?)|\n|6 | [What is Restful service?](#What is Restful service?)|\n|6 | [Explain the difference between Transport and Message Level Security](#Explain the difference between Transport and Message Level Security)|\n\n###  What is Windows Communication Foundation, WCF?\n\nWCF helps in building applications to communicate with each other. It is a framework that helps in managing distributed computing. WCF has a layered architecture. It is a part of the .Net Framework 3.0 \n\n### What are the components of WCF?\n\nWCF Service is composed of three components:\n\nService class: It implements the service needed.\n\nHost environment: is an environment that hosts the developed service.\n\nEndpoints: are the connection points for the clients to connect to the service. Clients find the end points through three components like service contract, binding, and address.\n\n### What is the difference between WCF and Web services?\n\nWCF has a variety of distributed programming infrastructures. WCF offers more flexibility and portability. WCF has better security mechanisms as compared to Web services. Transportation is easier in WCF.\n\n### What are different binding supported by WCF?\n\nDifferent bindings\n\nBuilt- in bindings and custom bindings. When the built in or system provided bindings are not suited for the requirement, custom bindings can be issued.\n\nThe system –Provided bindings are:\n\n1. BasicHttpBinding:- uses HTTP for transport .\n\n2. WSHttpBinding:- Used for non duplex services\n\n3. WSDualHttpBinding:- Used for Duplex services\n\n4. NetTcpBinding:- Used for cross machine communication\n\n5. NetPeerTcpBinding:- Used for multiple machine communication\n\n6. NetMsmqBinding:- queued binding Used for multiple machine communication.\n\n### What is duplex contracts in WCF?\n\nWCF allows duplex messaging pattern. Services can communicate with client through a callback. Duplex messaging in WCF can be done over different transports, like TCP, Named Pipes and even HTTP \n\n### How do we use MSMQ binding in WCF?\n\nMessage queue allows applications running at different times to send and read messages from queues. WCF uses transactional queue to capture messages, delivered and stored. A non transactional queue can be used as well, though it does not guarantee the assurance of messages being transferred. netMsmqBinding defines a queued binding. This can be used for cross machine communication. Properties of netMsmqBinding allow sending and receiving of messages.\n\n### Explain volatile queues and Dead letter queues.\n\nWCF also uses non transactional queues for storing messages. Such queues are volatile in nature. They are stored in memory and not used in transactions. On shutting down the machine, the queue is lost. They don’t guarantee the transfer of messages.\nDead letter queues: - Dead letter queues are used for failed or dead messages. When a message delivery fails, it is stored in a dead letter queue. MSMQ has two types of dead letter queues recording failed messages for transactional systems and non transactional systems.\n\n### What are the various ways of hosting a WCF service?\n\nWays of hosting WCF Service\n\n1. Self hosting: - The service code is embedded within the application code. An end point for the service is defined and an instance of SeriveHost is created. A method can be written then to call the service.\n\n2. Managed Windows services: - here, some hosting code is written in the application code. It consists of registering the application domain as a windows service.\n\n3. Internet Information Services: - Does not require any hosting code to be written in the application code. IIS host services can only use HTTP transport mechanism. IIS needs to be installed and configured on the server.\n\n4. Windows process activation service:- Does not require any hosting code to be written in the application code. WAS needs to be installed and configured on the server. WCF uses the listener adapter interface to communicate activation requests. Requests are transported over non HTTP protocols.\n\n### Explain transactions in WCF\n\nTransactions in WCF allow several components to concurrently participate in an operation. Transactions are a group of operations that are atomic, consistent, isolated and durable. WCF has features that allow distributed transactions. Application config file can be used for setting transaction timeouts.\n\n### What are different isolation levels provided in WCF?\nThe different isolation levels:\n\n1. READ UNCOMMITTED: - An uncommitted transaction can be read. This transaction can be rolled back later.\n\n2. READ COMMITTED :- Will not read data of a transaction that has not been committed yet\n\n3. REPEATABLE READ: - Locks placed on all data and another transaction cannot read.\n\n4. SERIALIZABLE:- Does not allow other transactions to insert or update data until the transaction is complete.\n\n### What are the advantages of hosting WCF services in IIS?\n\nAdvantages of hosting WCF services in IIS\n\n1. Provides process activation and recycling ability thereby increasing reliability\n\n2. It is a simplified way of deployment and development of hosted services.\n\n3. Hosting WCF services in IIS can take advantage of scalability and density features of ASP.NET\n\n### What are the various programming approaches for WCF?\n\nProgramming approaches for WCF\n\nImperative: - Different programming languages can be sued for implementing service logic\n\nConfiguration based:- Config files can be used to accomplish a task and end points along with security settings\n\nAttributes can be used for declaration for behaviors and contracts\n\n### What are WCF Service Endpoints? Explain.\n\nFor Windows Communication Foundation services to be consumed, it’s necessary that it must be exposed; Clients need information about service to communicate with it. This is where service endpoints play their role.\nA WCF service endpoint has three basic elements i.e. Address, Binding and Contract.\n\nAddress: It defines 'WHERE'. Address is the URL that identifies the location of the service.\n\nBinding: It defines 'HOW'. Binding defines how the service can be accessed.\n\nContract: It defines 'WHAT'. Contract identifies what is exposed by the service.\n\n### What is DataContractSerializer and How its different from XmlSerializer?\n\nSerialization is the process of converting an object instance to a portable and transferable format. So, whenever we are talking about web services, serialization is very important.\n\nWindows Communication Foundation has DataContractSerializer that is new in .NET 3.0 and uses opt-in approach as compared to \n\nXmlSerializer that uses opt-out. Opt-in means specify whatever we want to serialize while Opt-out means you don’t have to specify each \nand every property to serialize, specify only those you don’t want to serialize. DataContractSerializer is about 10% faster than XmlSerializer but it has almost no control over how the object will be serialized. If we wanted to have more control over how object should be serialized that XmlSerializer is a better choice.\n\n### How we can use MessageContract partially with DataContract for a service operation in WCF?\n\nMessageContract must be used all or none. If we are using MessageContract into an operation signature, then we must use MessageContract as the only parameter type and as the return type of the operation.\n### Please explain briefly different Instance Modes in WCF?\n\nWCF will bind an incoming message request to a particular service instance, so the available modes are:\n\nPer Call: instance created for each call, most efficient in term of memory but need to maintain session.\n\nPer Session: Instance created for a complete session of a user. Session is maintained.\n\nSingle: Only one instance created for all clients/users and shared among all.Least efficient in terms of memory.\n\n### How can you generate proxy class and configuration file for WCF service ?\n\nWCF provides an utility svcutil.exe which can be used to generate proxy class and configuration file. Eg:SvcUtil http://localhost:8002/MyService/ /out:Proxy.cs /noconfig\n\n### Is there any tool provided by Microsoft for editing configutation file ?\n\nYes. Microsoft provides an utility 'SvcConfigEditor.exe' that can edit any configuration fil\n\n### How can you test your new WCF service without writing any client application ?\n\nMicrosoft provides a tool which can be used to test any WCF service. To use this tool, open visual studio command prompt and execute the command 'wcftestclient.exe'. It will open a window where you can add many WCF services and test. You can also provide values for input parameters of WCF methods.\n\n### How can you configure reliability using .config file ?\n\u003cbindings\u003e\n\u003cnetTcpBinding\u003e\n\u003cbinding name = ReliableTCP\u003e\n \u003creliableSession enabled = \"true\"/\u003e\n \u003c/binding\u003e\n\u003c/netTcpBinding\u003e\n\u003c/bindings\u003e\n\n### How can you implement operation overloading in WCF service ?\n\nWe can implement operation overloading using 'Name' property of OperationContract attribute. For eg:\n[ServiceContract]\ninterface ICalculator\n{\n [OperationContract(Name = \"AddInt\")]\n int Add(int arg1,int arg2);\n [OperationContract(Name = \"AddDouble\")]\ndouble Add(double arg1,double arg2);\n}\n\n### What is Known Types ?\n\nBy default, you can not use a subclass of a data contract class instead of its base class. You need to explicitly tell WCF about the subclass using the KnownTypeAttribute.\nFor eg\n[DataContract]\n[KnownType(typeof(SubClass))]\nclass BaseClass\n{\n...\n}\n\n[DataContract]\nclass SubClass : BaseClass\n{\n...\n}\n\n### What is ServiceKnownType ?\n\nInstead of using the KnownType attribute on the base data contract, you can apply the ServiceKnownType attribute on a specific operation on the service side.Then,             only that operation(across all supporting services) can accept the known subclass.\n[OperationContract]\n[ServiceKnownType(typeof(SubClass))]\nvoid AddContact(BaseClass baseObject);\n\n### What is MessageContract ?\n\nWCF uses SOAP messages to transfer information from client to server and vice-versa. It converts data contract to SOAP messages. SOAP message contains Envelope, Header and Body. SOAP envelope contains name, namespace, header and body element. SOAP Header contains important information which are related to communication but not directly related to message. SOAP body contains information which is used by the target.\n\nWhen you use MessageContract then you have control over the SOAP message. However some restrictions are imposed as below:\n\nYou can have only one parameter for a service operation if you are using MessageContract.\n\nYou can return either void or MessageContract type from service operation. Service operation can not return DataContract type.\n\nService operation can accept and return only MessageContract type.\n\nSome important points about MessageContract:\nYou can mention the MessageHeader or MessageBodyMember to be signed or Encrypted using ProtectionLevel property. The order of the body elements are alphabetical by default.But you can control the order, using Order property in the MessageBody attribute.\n\n###  How is the service instance created? How can you manage or control WCF service instance creation ?\n\nClient request can be served by using single service instance for all users, one service instance for one client, or one instance for one client request. You can control this behavior by using the technique called Instance Management in WCF.\nThere are three instance modes supported by WCF:\n\nPer-Call: Service instance is created for each client request. This Service instance is disposed after response is sent back to client.\n\nPer-Session (default): Service instance is created for each client. Same instance is used to serve all the requests from that client for a session. When a client creates a proxy to particular service, a service instance is created at server for that client only. When session starts, context is created and when it closes, context is terminated. This dedicated service instance will be used to serve all requests from that client for a session. This service instance is disposed when the session ends.\n\nSingleton: All client requests are served by the same single instance. When the service is hosted, it creates a service instance. This service instance is disposed when host shuts down.\n\n### Can you control when the service instance is recycled ?\n\nYes, we can control when the service instance is recycled using the ReleaseInstanceMode property of the OperationBehavior attribute. You can control the lifespan of your WCF service. You can set the value of ReleaseInstanceMode property as one of the following:\n\nRealeaseInstanceMode.None: No recycling behavior.\n\nRealeaseInstanceMode.BeforeCall: Recycle a service object before an operation is called.\n\nRealeaseInstanceMode.AfterCall: Recycle a service object after an operation is called.\n\nRealeaseInstanceMode.BeforeAndAfterCall: Recycle a service object both before and after an operation is called.\n\n###  Can you limit how many instances or sessions are created at the application level ?\n\nYes, you can limit how many instances or sessions are created at the application level. For this, you need to configure throttling behavior for the service in its configuration file. Some of these important properties are:\nmaxConcurrentCalls limits the total number of calls that can currently be in progress across all service instances. The default is 16.\nmaxConcurrentInstances limits the number of InstanceContext objects that execute at one time across a ServiceHost. The default is Int32.MaxValue.\n\nmaxConcurrentSessions limits the number of sessions a ServiceHost object can accept. It is a positive integer that is 10 by default.\n\n### What are session modes in WCF ? How can you make a service as sessionful ?\n\nServiceContract attribute offers the property SessionMode which is used to specify the session mode. There are three session modes supported by WCF:\n\nSession.Allowed(default): Transport sessions are allowed, but not enforced. Service will behave as a per-session service only if the binding used maintains a transport-level session.\n\nSession.Required: Mandates the use of a transport-level session, but not necessarily an application-level session.\n\nSession.NotAllowed: Disallows the use of a transport-level session, which precludes an application-level session. Regardless of the service configuration, the service will always behave as a per-call service.\n\n[ServiceContract(SessionMode = SessionMode.NotAllowed)]\ninterface IMyContract\n{\n...\n}\n\n[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]\nclass MyService : IMyContract\n{\n...\n}\n\n\n### What is MEP (Message Exception Pattern) in WCF ?\n\nMEP describes the way in which Client and Server communicates. It describes how client and server would be exchanging messages to each other. \nThere are three types of message exchange patterns:\n\nRequest- Replay (default): When client makes a request to the WCF service, it waits to get response from service till receiveTimeout expires. If client does not get any response from the service before receiveTimeout expires, TimeoutException is thrown.\n\nOne-Way: When client makes a request to the WCF service, it does not wait for reply from the service. Service does not send any response to the sender, even if any error occurs in the communication. It does not support out or ref parameters. It does not return value to an operation.\n\nDuplex/Callback: Client and service can sends messages to each other by using One-way or request-reply messaging. This MEP is supported by only bidirectional-capable bindings like as WS Dual, TCP and IPC bindings.To make a duplex contract, you must also define a callback contract and assign the typeof that callback contract to the CallbackContract property of your service contract’s ServiceContract attribute.\n\n### What is Restful service ?\n\nREST stands for Representational State Transfer.\n\nREST is an architectural style for building distributed applications. It involves building Resource Oriented Architecture (ROA) by definding resources that implement uniform interfaces using standard HTTP verbs (GET, POST, PUT, and DELETE), and that can be located/identified by a Uniform Resource Identifier (URI).\n\nAny Service which follows the REST architecture style is called as RESTful service.\n\nCharacteristics of RESTful services:\n\nWe can load the server information using web url in the browser\n\nWe can access/modify the server resource using Url.\n\nIt allows the client, written in different language, to access or modify the resource in the server using URL.\n\nIt uses the http protocol for its communication and it is stateless.\n\nIt can transfer the data in XML,JSON,RSS,ATOM.\n\n### Explain the difference between Transport and Message Level Security.\n\nIn Windows Communication Foundation, we can configure to use security at different levels\n\nA.Transport Level security means providing security at the transport layer itself. When dealing with security at Transport level, we are concerned about integrity, privacy and authentication of message as it travels along the physical wire. It depends on the binding being used that how WCF makes it secure because most of the bindings have built-in security.\n\nB.Message Level Security\n\nFor Tranport level security, we actually ensure the transport that is being used should be secured but in message level security, we actually secure the message. We encrypt the message before transporting it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkansiris%2Fwcf-interview-questions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkansiris%2Fwcf-interview-questions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkansiris%2Fwcf-interview-questions/lists"}