WCF Data Services

  Home  Microsoft .Net Technologies  WCF Data Services


“WCF Data Services frequently Asked Questions by expert members with experience in WCF Data Services. These interview questions and answers on WCF Data Services will help you strengthen your technical skills, prepare for the interviews and quickly revise the concepts. So get preparation for the WCF Data Services job interview”



26 WCF Data Services Questions And Answers

1⟩ Explain WCF Basic binding type?

Offered by the BasicHttpBinding class, this is designed to expose a WCF service as a legacy ASMX web service, so that old clients can work with new services. When used by the client, this binding enables new WCF clients to work with old ASMX services.

 174 views

2⟩ What is WCF TCP binding type?

Offered by the NetTcpBinding class, this uses TCP for cross-machine communication on the intranet. It supports a variety of features, including reliability, transactions, and security, and is optimized for WCF-to-WCF communication. As a result, it requires both the client and the service to use WCF.

 135 views

3⟩ What is WCF Peer network binding type?

Peer network binding

Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast messages to it.

 146 views

4⟩ Explain WCF IPC binding type?

IPC binding

Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.

 161 views

5⟩ Explain WCF Web Service (WS) binding type?

Offered by the WSHttpBinding class, this uses HTTP or HTTPS for transport, and is designed to offer a variety of features such as reliability, transactions, and security over the Internet.

 152 views

7⟩ Explain Duplex WS binding?

Offered by the WSDualHttpBinding class, this is similar to the WS binding except it also supports bidirectional communication from the service to the client.

 157 views

8⟩ What is MSMQ binding?

Offered by the NetMsmqBinding class, this uses MSMQ for transport and is designed to offer support for disconnected queued calls.

 185 views

9⟩ Explain MSMQ integration binding?

Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients.

 151 views

10⟩ Explain WCF?

Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for services, enabling you to expose CLR types as services, and to consume other services as CLR types.

WCF is part of .NET 3.0 and requires .NET 2.0, so it can only run on systems that support it.

 163 views

12⟩ Do you know what is address in WCF and how many types of transport schemas are there in WCF?

Address is a way of letting client know that where a service is located. In WCF, every service is associated with a unique address. This contains the location of the service and transport schemas.

WCF supports following transport schemas

HTTP

TCP

Peer network

IPC (Inter-Process Communication over named pipes)

MSMQ

The sample address for above transport schema may look like

http://localhost:81

http://localhost:81/MyService

net.tcp://localhost:82/MyService

net.pipe://localhost/MyPipeService

net.msmq://localhost/private/MyMsMqService

net.msmq://localhost/MyMsMqService

 186 views

13⟩ Explain Service contracts?

Describe which operations the client can perform on the service.

There are two types of Service Contracts.

ServiceContract - This attribute is used to define the Interface.

OperationContract - This attribute is used to define the method inside Interface.

[ServiceContract]

interface IMyContract

{

[OperationContract]

string MyMethod( );

}

class MyService : IMyContract

{

public string MyMethod( )

{

return "Hello World";

}

}

 162 views

14⟩ Explain Data contracts?

Define which data types are passed to and from the service. WCF defines implicit contracts for built-in types such as int and string, but we can easily define explicit opt-in data contracts for custom types.

There are two types of Data Contracts.

DataContract - attribute used to define the class

DataMember - attribute used to define the properties.

[DataContract]

class Contact

{

[DataMember]

public string FirstName;

[DataMember]

public string LastName;

}

 169 views

16⟩ Do you know message contracts?

Allow the service to interact directly with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an existing message format we have to comply with.

 192 views

18⟩ Do you know what is endpoint in WCF?

Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint.

The Endpoint is the fusion of Address, Contract and Binding.

 139 views

19⟩ Can you explain how to define a service as REST based service in WCF?

WCF 3.5 provides explicit support for RESTful communication using a new binding named WebHttpBinding.

The below code shows how to expose a RESTful service

[ServiceContract]

interface IStock

{

[OperationContract]

[WebGet]

int GetStock(string StockId);

}

By adding the WebGetAttribute, we can define a service as REST based service that can be accessible using HTTP GET operation.

 178 views

20⟩ Do you know what is the address formats of the WCF transport schemas?

Address format of WCF transport schema always follow

[transport]://[machine or domain][:optional port] format.

for example:

HTTP Address Format

http://localhost:8888

the way to read the above url is

"Using HTTP, go to the machine called localhost, where on port 8888 someone is waiting"

When the port number is not specified, the default port is 80.

TCP Address Format

net.tcp://localhost:8888/MyService

When a port number is not specified, the default port is 808:

net.tcp://localhost/MyService

NOTE: Two HTTP and TCP addresses from the same host can share a port, even on the same machine.

IPC Address Format

net.pipe://localhost/MyPipe

We can only open a named pipe once per machine, and therefore it is not possible for two named pipe addresses to share a pipe name on the same machine.

MSMQ Address Format

net.msmq://localhost/private/MyService

net.msmq://localhost/MyService

 177 views