Back to: Dot Net Interview Questions and Answers
WCF Interview Questions and Answers
In this article, I am going to discuss the most frequently asked WCF Interview Questions and Answers. In the next article, I am going to discuss WCF Experienced Interview questions and answers. Let start the WCF Interview Questions and Answers discussion with the most basic question that asked in almost all interviews i.e. What is WCF.
What is WCF?
WCF stands for Windows Communication Foundation (WCF) and is a part of .NET Framework 3.0 which is considered as the Microsoft Service-Oriented Architecture (SOA) platform for building distributed and interoperable applications. WCF unifies ASMX, Remoting, and Enterprise Services stacks and provides a single programming model. WCF services are interoperable and support all the core Web services standards.
What is the version of the .NET framework in which WCF is released?
WCF – Windows Communication Foundation is released as part of .NET Framework 3.0. WPF (Windows Presentation Foundation), WF (Workflow Foundation), and Card Space are also part of .NET Framework 3.0.
What is a distributed application?
In simple terms, we can say that a distributed application is an application where parts of it run on 2 or more computers. Distributed applications are also called connected systems.
Examples: A web application running on one machine and a web service that this web application is consuming is running on another machine.
An enterprise web application may have the following tiers and each tier may be running on a different machine
- Presentation tier
- Business tier
- Data Access tier
Why we build distributed applications?
There are several reasons for this
- An enterprise application may need to use the services provided by other enterprises. For example, an eCommerce application may be using the Paypal service for payments.
- For better scalability. An enterprise web application may have the Presentation tier, Business tier, and Data Access tier and each tier may be running on a different machine.
What is an interoperable application?
An application that can communicate with any other application that is built on any platform and using any programming language is called an interoperable application. Web services are interoperable whereas .NET remoting services are not. Web services can communicate with any application built on any platform whereas a .NET remoting service can be consumed only by a .net application.
What technology choices did we have before WCF to build distributed applications?
- Enterprise Services
- Dot Net Remoting
- Web Services
What are the core components of WCF Service?
A WCF service has at least the following core components.
- Service Class: A service class implementing in any CLR-based language and expose at least one method.
- Hosting Environment: a managed process for running service.
- Endpoint: a client uses it to communicate with the service.
What are the new features introduced in WCF 4.5?
Windows Communication Foundation v4.5 was released with a number of cool features. These important features are:
- Simplified Configuration files
- ToolTip and Intellisense support
- Task-based asynchronous Programming Model
- BasicHttpsBinding support
- Single WSDL Document
- WCF Configuration Validation
- ASP.NET Compatibility Mode changed
- Contract First Development
- Multiple Authentication Types
- XmlDictionaryReaderQuotas default value changed
- UDP Transport Support and many more…
What is the difference between WCF and ASMX Web services?
The basic difference is that the ASMX web service is designed to send and receive messages using SOAP over HTTP only. While WCF service can exchange messages using any format (SOAP is the default) over any transport protocol (HTTP, TCP/IP, MSMQ, Named Pipes, etc).
ASMX Web Services:
- Can only be hosted in IIS.
- It only supports HTTP Protocol
- Limited Security
- It uses XmlSerializer
WCF:
- Multiple Hosting options such as WAS, Console, IIS, WCF provide host, etc.
- Supports HTTP, TCP. MSMQ, NamedPipes.
- A consistent security programming Model
- Uses DataContractSerializer
What is the difference between Service EndPoint and Client Endpoint?
As we already understood the concept of an Endpoint and its ABC (Address, Binding, Contract). Both Service and Client Endpoint has the same ABC but we think in different perspective while working with them. We can differentiate between Service and Client Endpoint with respect to Address, Binding, and Contract as:
Service EndPoint:
- WHERE: URL of hosted service. (Address)
- WHAT: bindings being used. (Binding)
- CONTRACT: Service Contract i.e. interfaces (Contract)
Client EndPoint:
- WHERE: where to connect with hosted service.
- WHAT: binding supported by service.
- CONTRACT: what to pass and expect while communicating with service.
Why should we use WCF?
Let’s take this scenario. We have 2 clients and we need to implement a service for them.
- The first client is using a Java application to interact with our service so for interoperability this client wants messages to be in XML format and the protocol to be HTTP.
- The second client uses .NET so for a better performance this client wants messages formatted in binary over TCP protocol.
Without WCF
To satisfy the first client requirement we end up implementing an ASMX web service and to satisfy the second client requirement we end up implementing a remoting service. These are 2 different technologies and have completely different programming models. So, the developers have to learn different technologies. So, to unify and bring all these technologies under one roof Microsoft has come up with a single programming model that is called as WCF – Windows Communication Foundation.
With WCF,
We implement one service and we can configure as many endpoints as want to support all the client needs. To support the above 2 client requirements, we would configure 2 endpoints. In the endpoint configuration, we can specify the protocols and message formats that we want to use.
What is the advantage of using WCF over other distributed programming models like Web Services (ASMX), .NET Remoting, Enterprise Services stack, etc.?
This is one of the frequently asked WCF Interview Questions and Answers. To understand the advantage of using WCF over other distributed programming models like Web Services (ASMX), .NET Remoting, Enterprise Services stack, etc, let’s consider the following scenario. We have developed an application using web services. As we know web services use HTTP protocol and XML SOAP formatted messages, they are good for developing interoperable applications in a heterogeneous environment. We have a new client. Our new client is using .NET and he wants binary formatted messages over TCP protocol because interoperability is not a concern and binary formatted messages over TCP protocol are much faster than XML SOAP formatted messages over HTTP. To satisfy the requirement of this client, now we cannot use our existing web service. So, we have to develop a brand-new remoting application from the scratch. The business functionality is the same in web services and remoting applications. Since our different clients have different requirements, we ended up creating the same business application using web services and remoting technologies. This approach has several disadvantages as listed below.
- Developers have to be familiar with two different technologies (Web Services and Remoting).
- We end up creating duplicate business applications with different technologies which also leads to maintenance overhead.
On the other hand, WCF unifies Web Services, .NET Remoting, and Enterprise Services stacks under one roof. For the same requirement that we have seen until now, we just create one application and expose multiple endpoints to satisfy the requirements of multiple clients. In WCF configuration drives protocol choices, messaging formats, process allocation, etc. WCF services are loosely coupled, meaning that a WCF service is not bound to a particular protocol, encoding format, or hosting environment. Everything is configurable.
Why WCF Services are considered loosely coupled?
WCF Services are considered loosely coupled because WCF services are not tightly bound to a particular protocol, encoding format, or hosting environment. All of these are configurable. At the time of designing WCF services, we do not have to worry about what protocol, encoding format, or hosting environment to use to expose the service. We can worry about all these at the time of deployment.
What are the 3 things that a WCF Services endpoint must-have? OR
What is the ABC of a WCF service?
- Address – The address where the WCF Service is hosted. In other words, what is the location of the service? An address could be an IP Address, server name, URL, and so on.
- Binding – The binding that decides the protocol, message encoding, and security to use. Binding also decides whether to use reliable messaging and transaction support. That means it’s all about how the messages are handled on the service side and the client-side.
- Contract – The service contract defines what service operations are available as part of that service to the client for consumption.
So, the Address (A), Binding (B), and Contract (C) are called the ABC of the service endpoint. To reach an endpoint, the Address (Where), the Binding (How) and the Contract (What) are really important for establishing communication.
What is the role of WSDL in WCF? OR
What is WSDL?
This is one of the frequently asked WCF Interview Questions and Answers. WSDL stands for Web Service Description Language. The WCF service exposes the WSDL document for the clients to generate proxies and the configuration file. The WSDL file provides the following information for the consumers of the WCF service.
- Provides the information about the service contract and operations available.
- Provides information about all the endpoints exposed by the WCF service.
- Provides information about the messages and types that can be exchanged between the client and the WCF service.
- WSDL also provides any information about the policies used.
Is it possible for a WCF service to implement multiple service contracts?
Yes, we make the service class implement multiple service interfaces, and then expose each service using a different endpoint.
In how many ways metadata can be exposed to the clients in WCF?
In WCF Metadata can be exposed in 2 ways.
- WSDL – Default format and it doesn’t support non-http protocols.
- Mex – New improved version and supports non-http protocols and it has some additional security features.
It will expose metadata via WSDL through the default URL, even if we don’t have defined a mex endpoint for our service
What is the tool that a client application can use to generate the proxy for a WCF service?
Service Utility (svcutil.exe) can be used by the clients to generate the proxy and configuration file. For the client to be able to generate proxies, the service should enable metadata exchange.
Define Service Contracts and Operation Contracts in WCF?
Service Contract- An interface that exposes the service operations is usually decorated with the ServiceContract attribute. Always provide meaningful Namespace and Name to a service contract. A service contract defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do. It may have service-level settings, such as the name of the service and namespace for the service.
Operation Contract – All methods in a service contract should have the OperationContract attribute. We can also provide explicit Name, Action, and ReplyAction. An operation contract is defined within a service contract. It defines the parameters and returns type of an operation. An operation contract can also define operation-level settings, like the transaction flow of the operation, the directions of the operation (one-way, two-way, or both ways), and the fault contract of the operation.
Can we apply the ServiceContract attribute to a class rather than an interface in WCF?
Yes, a ServiceContract attribute can be applied either to a class or an interface but defining service contracts using interfaces rather than classes has the following benefits.
- Defining service contracts using interfaces remove coupling to service implementation. Later the implementation can be changed at will without affecting the clients.
- Defining service contracts using interfaces, also allows a service to implement more than 1 contract.
What is the purpose of the MessageParameter attribute in WCF?
MessageParameter attribute is used to control the parameter and returned object names from a service operation.
What is serialization with respect to WCF?
With respect to WCF, Serialization is the process of converting an object into an XML representation. The reverse process that is reconstructing the same object from the XML is called Deserialization.
What are the different options available to serialize complex types that are sent and received between clients and services in WCF?
This is one of the frequently asked WCF Interview Questions and Answers. The following are the different options available to serialize complex types that are exchanged between clients and services in WCF. These options have their own advantages and disadvantages. A data contract is a preferred way to serialize complex types in WCF.
- Serializable types – Use the Serializable attribute on the type that we want to serialize
- Data contracts – Use the DataContract attribute on the type and the DataMember attribute on every member of the type that we want to serialize. We can apply the DataMember attribute either on a field or a property.
- Known types – Use Known types to enable polymorphic behavior in service contracts.
- IXmlSerializable – IXmlSerializable types provide XSD schema to Web Services Description Language (WSDL) and metadata exchange (MEX).
By default, WCF uses DataContractSerializer. For a complex type like Customer, Employee, Student to be serialized, the complex type can either be decorated with
- SerializableAttribute or
- DataContractAttribute
With .NET 3.5 SP1 and above we don’t have to explicitly use DataContract or DataMember attributes. The DataContractSerializer will serialize all public properties of our complex type in alphabetical order. By default, private fields and properties are not serialized.
If we decorate a complex type with [Serializable] attribute the DataContractSerializer serializes all fields. With the [Serializable] attribute we don’t have explicit control on what fields to include and exclude in serialized data. And it cannot serialize properties.
If we decorate a complex type with [Datacontract] attribute, the DataContractSerializer serializes the fields marked with the [DataMember] attribute. The fields that are not marked with the [DataMember] attribute are excluded from serialization. The [DataMember] attribute can be applied either on the private fields or public properties.
In WCF, the most common way of serialization is to mark the type with the DataContract attribute and mark each member that needs to be serialized with the DataMember attribute.
If we want to have explicit control on what fields and properties get serialized then use DataContract and DataMember attributes.
- Using DataContractAttribute, we can define an XML namespace for our data
- Using DataMemberAttribute, we can define Name, Order, and whether if a property or field IsRequired or not. Also, serialize private fields and properties
What is the disadvantage of using the Serializable attribute to serialize a complex type that is sent and received between clients and services in WCF?
When we decorate a class with the Serializable attribute, all the fields of the class are serialized regardless of the accessibility. We do not have control over what to serialize and what not to serialize. Also, we will not have any control over naming conventions or data types.
What is the preferred way for serializing complex types in WCF?
This is one of the frequently asked WCF Interview Questions and Answers. The preferred way for serializing complex types in WCF is to use data contracts. Using Data Contracts provides us with the following advantages.
- Using the DataMember attribute, we can control which members of the class to serialize.
- We can also control the order in which members are serialized using the Order parameter of the DataMember attribute.
- We can also provide explicit Names to the serialized members using the Name parameter of the DataMember attribute.
- We can also specify if a member is required or optional using the IsRequired parameter of the DataMember attribute.
Consider the example below which uses Name, IsRequired, and Order parameters of the DataMember attribute to serialize CustomerId property. By the way, the DataMember attribute can be used with either fields or properties. If you do not specify the order in which members are serialized, then by default alphabetical ordering is done by the DataContractSerializer.
Why we use Known Type in WCF?
If we have classes related by inheritance the WCF service generally accepts and returns the base type. If we expect the service to accept and return inherited types then use the KnownType attribute.
Why Message Contract?
With Data Contracts we have very limited control over the SOAP XML request and response messages that are generated. Use Message Contracts if we want to have full control over the generated XML SOAP messages. Few examples of when Message Contracts can be handy
- Include some custom data in the SOAP header. In general SOAP headers are used to pass user credentials, license keys, session keys, etc.
- Change the name of the wrapper element in the SOAP message or remove it altogether.
Explain the significance of the MessageContract attribute? OR
Why and when do we use the MessageContract attribute in WCF?
This is one of the frequently asked WCF Interview Questions and Answers. There are several advantages of using the MessageContract attribute in WCF. MessageContract attribute can be used for
- Adding custom headers to the message.
- Controlling message wrapping.
- Controlling signing and encryption of messages.
MessageContract attribute provides us with greater control over message headers and body elements. MessageContract attribute converts a type to a SOAP message. The example below shows how to use IsWrapped and ProtectionLevel parameters of the MessageContract attribute. We may also set an explicit Name and Namespace.
MessageContract attribute is supported by MessageHeader attribute and MessageBodyMember attribute. We can apply the MessageHeader attribute to fields or properties of the message contract. This is a simple technique for creating custom headers. We can provide Name, Namespace, and ProtectionLevel. We may also set SOAP protocol settings like Relay, Actor, Must Understand.
MessageBodyMember attribute can also be applied to fields or properties of message contracts. It can have several body elements. This is equivalent to multiple parameters in operation and this is the only way to return multiple complex types. It is suggested as a good practice to always supply Order. You can also set Name, Namespace, ProtectionLevel. The example below shows how to use MessageHeader and MessageBodyMember attributes.
What is WS-Policy? OR
What is Web Services Policy?
Web Services Policy or WS-Policy is an interoperable standard for describing policies that influence communication with the clients. Usually, WS-Policy is included in the WSDL contract exposed by the WCF service, although it is optional.
What is the use of WS-Policy?
WS-Policy is generally used for
- Describing protocols for accessing operations
- Security
- Reliable messaging
- Transactions
- Message encoding (Message Transmission Optimization Mechanism [MTOM])
- Other protocols
We can specify the above settings in WSDL directly without a policy section, but the disadvantage is that once published, the WSDL contract is final. If the clients have to communicate with a WCF service that has changed the settings in the WSDL, the clients need to rebuild the proxy and configuration or at least the changes to the WSDL contract must support backward compatibility.
The advantage of using WS-Policy is that it can change over time, and the clients can discover the changed policy to communicate via metadata exchange. But keep in mind that, you can only change the policy safely if clients are positioned to handle dynamic changes.
What are SOAP Faults in WCF?
This is one of the frequently asked WCF Interview Questions and Answers. Common language runtime (CLR) exceptions do not flow across service boundaries. At the maximum, a CLR exception may propagate up to the service tier from business components. Unhandled CLR exceptions reach the service channel and are serialized as SOAP faults before reporting to clients. An unhandled CLR exception will fault the service channel, taking any existing sessions with it. That is why it is very important to convert the CLR exceptions into SOAP faults. Where possible, throw fault exceptions
SOAP faults are standards-based and interoperable. There are 2 formats used by SOAP faults, SOAP 1.1 and SOAP 1.2. SOAP format depends on the binding used.
What happens if there is an unhandled exception in WCF?
This is one of the frequently asked WCF Interview Questions and Answers. If there is an unhandled exception in WCF, the service model returns a general SOAP fault that does not include any exception-specific details by default. However, we can include exception details in SOAP faults, using the IncludeExceptionDetailsInFaults attribute. If IncludeExceptionDetailsInFaults is enabled, exception details including stack trace are included in the generated SOAP fault. IncludeExceptionDetailsInFaults should be enabled for debugging purposes only. Sending stack trace details is risky.
What are bindings in WCF?
Bindings in WCF define the configuration of the communication channels between clients and services. Binding specifies
- Transport Protocol
- Message encoding
- Security Mechanism
- Reliable Messaging
- Transactions Support
What are different Transport protocols available in WCF?
- TCP
- HTTP
- Named Pipes
- MSMQ
What message encoding formats are available in WCF?
- Text – For interoperability
- MTOM (Transmission Optimization Mechanism) – For transferring large objects
- Binary – For speed
What are the 2 ways available for configuring bindings in WCF?
- Declaratively using a configuration file
- Programmatically in the code.
- Using a configuration file has several advantages.
List a few standard bindings available in WCF?
- BasicHttpBinding
- NetPeerTcpBinding
- WSFederationHttpBinding
- NetNamedPipeBinding
- WSHttpBinding
- WSDualHttpBinding
- NetTcpBinding
- NetMsmqBinding
- MsmqIntegrationBinding
Can we create a customized binding in WCF?
Yes, bindings in WCF are completely extensible and we can create a customized one
What is the different message exchanging patterns available in WCF?
This is one of the frequently asked WCF Interview Questions and Answers. There are 3 main different message exchanging patterns available in WCF.
- Request-Reply – In the request-reply pattern, a client application sends a message to a WCF service and then waits for a reply. This is the classic and most commonly used message exchange pattern in WCF.
- One-Way – In a one-way message exchange pattern no response is sent back, even if there is an exception. In the one-way message exchange pattern, a client application sends a message to a WCF service but the service does not send a reply message to the client. We can use this pattern when a client requests the service to take an action but does not need to wait for a reply.
- Duplex – In the request/reply and one-way message exchange patterns, only the client can initiate communication. In the duplex pattern, both the client and the service can initiate communication. The client calls a method of the service. The service can then use a client callback to call a method in the client. We can use this pattern when we want the service to send a notification or alert to the client after the client has called the service.
What is the default message exchange pattern used in WCF?
Request/Reply
How do you set up a one-way operation?
Set OperationContractAttribute’s IsOneWay property to true. An example is shown below.
![]() |
What is MTOM?
MTOM stands for Message Transmission Optimization Mechanism and is an Interoperable standard that reduces the overhead of large binary data transfer. Removes bloat and processing overhead of base64 encoded data. Improves overall message transfer performance.
What are the instancing modes available in WCF?
- Percall
- PerSession
- Single
What are the advantages of using Percall instancing mode in WCF?
In a Percall instance mode, a new service instance (object) is created for each call. The following are the advantages and Disadvantages of Percall instance mode.
Advantages:
- Less memory consumption
- Service instances are freed
- Concurrency is not an issue
- PerCall services increase overall throughput
Disadvantages:
- State not maintained between calls
What are the four-session types available in WCF?
- Transport session
- Reliable sessions
- Secure sessions
- Application sessions
What are the advantages and disadvantages of using PerSession instancing mode in WCF?
A new service object gets created for each client/proxy. The following are the advantages and Disadvantages of the PerSession instance mode.
Advantages:
- State maintained by the service instance
Disadvantages:
- Less throughput, greater memory consumption
- Concurrency issues for multithreaded clients
Name a few bindings that can support PerSession instancing mode?
- NetTcpBinding
- NetNamedPipeBinding
- WSHttpBinding
- WSFederationHttpBinding
- WSDualHttpBinding
What is the default Application Session timeout in WCF?
Session lifetime lasts 10 minutes by default, for Application Session.
What are the advantages and disadvantages of using Single, Instancing mode in WCF?
In a single instancing mode, a single service object is created for all calls from all clients and sessions this type of WCF service is also called a singleton service. The following are the advantages and Disadvantages of the Single instance mode.
Advantages:
- State maintained by the service instance
Disadvantages:
- Least throughput
- Potentially greater memory consumption
- Concurrency issues
What are the general guidelines for choosing an instancing mode?
In general, for scalability and throughput prefer to use PerCall services where ever possible. Use PerSession services only when necessary, but keep in mind the overhead of sessions and session timeouts. Try to avoid singletons almost always. Singleton services could be useful on client machines for shared functionality. These are only general guidelines, and your selection depends on what you are trying to achieve.
What are the different concurrency modes available in WCF?
- Single
- Reentrant
- Multiple
Are WCF services protected from concurrent access by default?
Yes, WCF services are protected from concurrent access by default, as the concurrency mode of a WCF service is set to Single by default.
Explain Single Concurrency Mode?
In a Single concurrency mode, only one request is processed by the same service instance. A lock is acquired while a request is processed by a service instance. Other threads, if any, are queued until they timeout. Once the lock is released when the current request completes, the next thread in the queue can then access the objects.
What effect does the Single concurrency mode setting have on PerCall, PerSession, and Singleton services?
- PerCall services and Single Concurrency mode: A new service instance is allocated for each thread. Here, concurrency is not an issue and Single-mode setting has no impact on the throughput and concurrent calls can be processed.
- PerSession services and Single Concurrency mode: Service instances are protected against multithreaded clients. Single-mode impacts throughput of the single client but multiple clients can get through and concurrent calls can be processed.
- Singleton services and Single Concurrency mode: Service instances are protected against any concurrent calls. Single concurrency mode impacts the throughput of the singleton. Multiple threads and clients cannot get through and no concurrent calls can be processed
Explain Reentrant Concurrency Mode?
Reentrant concurrency mode is useful when services issue callbacks to clients If callback operations are not one-way. Services release the acquired lock upon exit to make the callback and another thread is able to acquire the lock. In this case, the return from the callback will queue.
What effect does the Reentrant concurrency mode setting have on PerCall, PerSession, and Singleton services?
- PerCall services and Reentrant Concurrency mode: In a case where PerCall services may need reentrancy, if we set the concurrency mode to Single, deadlock is guaranteed, whereas if it is In Reentrant mode, we will have no problem.
- PerSession services and Reentrant Concurrency mode: PerSession services allow a multithreaded client to access the service instance
- Singleton services and Reentrant Concurrency mode: Singleton services allow any threads to access the service instance
What is the effect of Multiple concurrency mode on PerSession services with multithreaded clients?
PerSession services with multithreaded clients can have increased throughput, with Multiple concurrency mode, as no locks are acquired when requests are being processed by a service instance. However, care should be taken to protect shared resources.
What are different .NET multithreading techniques available to protect a shared resource?
- Monitor
- Mutex
- Semaphore
- ReadWriterLock
- Interlocked
What are the factors that can influence overall throughput for a service, when multiple concurrency modes are enabled?
- Instancing mode
- Concurrency mode
- Throttling behavior
What is ServiceThrottleBehavior?
ServiceThrottleBehavior provides several settings for throughput control, as shown below.
- MaxConcurrentCalls: Maximum concurrent requests allowed. The default is 16.
- MaxConcurrentInstances: Maximum concurrent service instances allowed. The default is int.MaxValue.
- MaxConcurrentSessions: Maximum concurrent active sessions. This includes transport, reliable, secure, and application sessions. The default is 10.
How to control the WCF service session timeout?
This is one of the frequently asked WCF Interview Questions and Answers. The default session timeout is 10 minutes. If we want to increase or decrease the default timeout value
Step 1: Set receiveTimeout attribute of the respective binding element as shown below. In the example below, we have configured the session timeout for 10 seconds.
<bindings>
<netTcpBinding>
<binding name=”netTCP” receiveTimeout=”00:00:10″></binding>
</netTcpBinding>
</bindings>
Step 2: Associate the binding element with the endpoint using bindingConfiguration attribute as shown below.
<endpoint address=”SimpleService” binding=”netTcpBinding” contract=”SimpleService.ISimpleService” bindingConfiguration=”netTCP”/>
What happens when the session timeout is reached?
When the session timeout is reached, the connection to the WCF service is closed. As a result, the communication channel gets faulted and the client can no longer use the same proxy instance to communicate with the service. This also means that along with the session, the data in the service object is also lost. After the session has timed out,
1. On the first attempt to invoke the service using the same proxy instance would result in the following exception.
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was ’00:00:59.9355444′.
2. On the second attempt, the following exception will be thrown
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
How to fix the communication channel is in a faulted state exception
- Put the line that calls the service should in the try block
- Catch the CommunicationException
- Check if the communication channel is in a faulted state and create a new instance of the proxy class.
Can we have multiple endpoints for different binding types in order to serve different types of clients?
Yes, we can have multiple endpoints for different binding types. For example, an endpoint with wsHttpBinding and another one with netTcpBinging.
What are the hosting options for WCF Services? Explain.
For a service to host, we need at least a managed process, a ServiceHost instance, and an Endpoint configured. Possible approaches for hosting a service are:
Hosting in a Managed Application/ Self Hosting
- Console Application
- Windows Application
- Windows Service
Hosting on Web Server
- IIS 6.0 (ASP.NET Application supports only HTTP)
- Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP,
NamedPipes, MSMQ.
In the next article, I am going to discuss WCF Experienced Interview questions with answers. Here, in this article, I try to explain the most frequently asked WCF Interview Questions and Answers. I hope you enjoy this WCF Interview Questions and Answers article. I would like to have your feedback. Please post your feedback, question, or comments about this WCF Interview Questions and Answers article.