WCF Interview Questions and Answers

    1 Votes

31) Explain “One-Way” mode in WCF?

In this mode client send a request to the server but does not wait till the response comes and does not care whether the request is failed or succeeded. Client will not blocked in this case till it receives the response.

32) Explain “Callback” mode in WCF?

This is the special mode of WCF where WCF on call back calls the method of client and in this scenario WCF service acts like a client and client acts like a service. But “HTTPBinding” does not support this mode we have to switch to “WSDualHttpBinding”.

33) What are Events in WCF?

Events allow the clients to get notified once it’s occurred in service side. Events will always result in direct call from client. Since service firing the event it’s called the publisher and since client is being notified about the event it is called subscriber.

34) What is the namespace used for WCF?

Namespace “System.ServiceModel” is used for WCF.

35) What are the isolation levels in WCF?

Below are the list of isolation levels in WCF –

  • Read Committed
  • Read Uncommitted
  • Serializable
  • Repeatable Read

36) List out Address format of all the bindings in WCF?

Below are the formats of address and its respective bindings –

  • TCF Address Format - net.tcp://local host:portnumber
  • HTTP Address Format - http://local host:portnumber
  • MSMQ Address Format - net.msmq://local host:portnumber

37) What is WCF RIA?

This is the framework for developing n-tier application for RIA (Rich Internet App). This is used in for Rich Internet Apps like Silverlight, AJAX etc. It solves major problems like – Tight Coupling.

38) How to generate proxy for WCF?

Proxy can generated from below steps –

  • Using Visual Studio
  • Using SvcUtil

39) Explain how to generate proxies using Svcutil in WCF?

SvcUtil is a command line utility. We can write the below command to generate proxy –

svcutil /t:code http://<mycreatedserviceurl>/out:<file_name>.cs /config:<file_name>.config

40) What you mean by “Transport Reliability” ?

Transport Reliability” meaning the guaranteed delivery of packets over network as protocol TCP does. It is not only the guaranteed delivery of packets it maintains the order of the packets as well.

41) What are default endpoints in WCF?

If service does not have any endpoints either in config or in program, by default WCF adds up one endpoint to the service created.

42) How to enable metadata information of the service?

Below are the ways to enable the metadata for WCF –

  • For Default Endpoint - <serviceMetadata> tag is used in web.config file without specifying the endpoint.
  • For Custom Endpoint - - <serviceMetadata> tag is used in web.config file with specifying the defined endpoint.

43) Which bindings are used for metadata configuration in WCF?

Below are the list of bindings that are used for metadata –

  • mexHttpBinding
  • mexNamedPipeBinding
  • mexHttpsBinding
  • mexTcpBinding

44) What is the way to test our WCF application without creating client application?

Tool called - “wcftestclient.exe” used for testing the WCF service without creating a client application. We can open this tool from visual studio command prompt.

45) How to configure the reliability in configs file?

In config file we can use the tag of reliability as in the below code snippet –

<bindings>
<netTcpBinding>
<binding name = "MyTestBinding">
<reliableSession enabled = "true"/>
</binding>
</netTcpBinding>
</bindings>

46) Can overload methods in WCF? If Yes, How?

Yes we can overload operations or methods in WCF. Below is the sample code depicts the same –

[ServiceContract]
interface IMyTestCalculator
{
[OperationContract(Name = "AddTestInteger")]
int AddTest(int pararm1,int pararm2);
[OperationContract(Name = "AddTestDouble")]
double AddTest(double pararm1,double pararm2);
}

47) Explain Known Types in WCF?

If we define the complex complex class as the property of class would give a hard time for the compiler during deserilization process. So we will use attribute - KnownType to the parent class.

48) Give an example for KnownType?

Please check the below example for KnowTypes –

[KnownType(typeof(TestClassCar))]
[KnownType(typeof(TestClassTruck))]
[DataContract]
public class TestClassVehicle
{
}
[DataContract]
public class TestClassCar : TestClassVehicle
{
} [DataContract]
public class TestClassTruck : TestClassVehicle
{
}

49) Explain ServiceKnownType in WCF?

ServiceKnownType is used at Opeartion/Method level. When serviceknowntype is applied to the operation then that only operation will use known type.

50) Give an example for ServiceKnownType?

Below is the sample code snippet –

public Interface ITestVehicleService
{
[ServiceKnownType(typeof(TestClassCar))]
[ServiceKnownType(typeof(TestClassTruck))]

[OperationContract]
Vehicle AddNewTestVehicle(TestClassVehicle myVehicle);
[OperationContract]
bool UpdateTestVehicle(TestClassVehicle myTestVehicle);
}

51) What are Fault Contracts in WCF?

This contract is used to raise the error from service side or in simple words client will come to know about the service error from fault contract.

52) Write a code snippet for Fault Contract in WCF Service?

Below is the code snippet for fault contract –

public Interface ITestVehicleService
{
[ServiceKnownType(typeof(TestClassCar))]
[ServiceKnownType(typeof(TestClassTruck))]

[OperationContract]
Vehicle AddNewTestVehicle(TestClassVehicle myVehicle);
[OperationContract]
[FaultContract(typeof(VehicleFault))]
bool UpdateTestVehicle(TestClassVehicle myTestVehicle);
}
[DataContract]
public class VehicleFault
{
private string vehicle;
private string problemType;
[DataMember]
public string Vehicle
{
get { return vehicle; }
set { vehicle = value; }
}
[DataMember]
public string ProblemType
{
get { return problemType; }
set { problemType = value; }
}
}
Page 3 of 4

Popular Videos

communication

How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

C# Interview Questions
.Net Framework Interview Questions and Answers
ADO.Net Interview Questions and Answers for Freshers, Experienced
ASP.Net Interview Questions and Answers
ASP.Net MVC Interview questions and Answers
ASP.Net Web API Interview Questions
Top 50 Entity framework interview questions & answers