WCF Interview Questions and Answers
Question - 51 : - What are the duplex contracts in WCF?
Answer - 51 : - In WCF, Duplex messaging or call-back is used to communicate with the client. Over different transport system Duplex messaging in WCF is done like TCP, Named pipe and even HTTP. Collectively this is known as duplex contracts in WCF. Basically duplex service contract is a message exchange pattern in which both endpoints can send messages to the other independently. A duplex service, therefore, can send messages back to the client endpoint, providing event-like behavior. Duplex communication occurs when a client connects to a service and provides the service with a channel on which the service can send messages back to the client. Note that the event-like behavior of duplex services only works within a session.
Question - 52 : - What is the usage of DataContracts in WCF?
Answer - 52 : - In WCF, we can communicate with the server from our client through a message. So messages will be going to and fro between server and client. For security purpose, we are serializing the messages sent across the wire.
"[DataContact]" attribute is given at class level to serialize the class by using "[Datamember]" attribute over properties.
Question - 53 : - How would you enable the metadata information of the service?
Answer - 53 : - Following are two ways to enable the metadata for WCF:
For Default Endpoint: tag is used in web.config file without specifying the endpoint.
For Custom Endpoint: tag is used in web.config file with specifying the defined endpoint.
Question - 54 : - Which bindings are used for metadata configuration in WCF?
Answer - 54 : - A list of bindings that are used for metadata:
o mexHttpBinding
o mexNamedPipeBinding
o mexHttpsBinding
o mexTcpBinding
Question - 55 : - How can you test a WCF application without creating a client application?
Answer - 55 : - There is a tool called - "wcftestclient.exe" used for testing the WCF service without creating a client application. This tool can be opened from visual studio command prompt.
Question - 56 : - What is the transport and message reliability?
Answer - 56 : - Transport reliability: It offers point-to-point guaranteed delivery at the network packet level, as well as guarantees the order of the packets.
Message reliability: It deals with reliability with message level independent of how many packets are required to deliver the message.
Question - 57 : - What is Transport Reliability in WCF?
Answer - 57 : - "Transport Reliability" specifies the guarantee of delivering packets over a network as protocol TCP does. It also maintains the order of the packets as well as delivering of packets.
Question - 58 : - ) What is the usage of "receiveTimeout" property in WCF?
Answer - 58 : - The "recieveTimeout" property is used to get/set the time interval to makes a connection active.
Question - 59 : - Which styles of models are supported in WCF?
Answer - 59 : - WCF service supports 2 styles of models:
RPC style: In RPC style we can use the serialize types and it provides the feature that is available for local calls.
Message style: In message style WCF allows the message header to be customized and it also allows us to define the security for body and header messages.
Question - 60 : - What is the one-way mode in WCF? Explain.
Answer - 60 : - In WCF one-way mode, a client sends a request to the server but does not wait till the response comes. It does not care if the request is failed or succeeded. The Client will not be blocked in this case until it receives the response.