WCF Interview Questions and Answers (209) - Page 4

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
Can we have a message contract as input parameter and data contract as returned parameter in a single operation contract?

No, Input and return parameter should be same as Message contract if we want to use message contract in a operation contract.
What is Asynchronous Messaging ?

Asynchronous messaging describes a way of communications that takes place between two applications or systems, where the system places a message in a message queue and does not need to wait for a reply to continue processing.
What is the key architectural principles behind Service Oriented Architecture (SOA) ?

Its the ability to re-use existing software assets whenever possible and to expose the functionality of these assets as a set of services.
Which namespace is used by WCF to define services and their operations ?

NOTE: This is objective type question, Please click question title for correct answer.
What does the namespace "System.Runtime.Serialization" exactly do in WCF ?

WCF uses the class to convert objects into a stream of data suitable for transmitting over the network (this process is known as Serialization). It also uses them to convert a stream of data received from the network back into objects (De-Serialization).
Which file specifies the name and location of the class that implements the WCF service ?

NOTE: This is objective type question, Please click question title for correct answer.
Why in WCF, the "httpGetEnabled" attribute is essential ?

The attribute "httpGetEnabled" is essential because we want other applications to be able to locate the metadata of this service that we are hosting.

<serviceMetadata httpGetEnabled="true" /> 


Without the metadata, client applications can't generate the proxy and thus won't be able to use the service.


Akiii
What is the former name of Windows Communication Foundation (or WCF) ?

NOTE: This is objective type question, Please click question title for correct answer.
What is "Automatic activation" in WCF ?

Automatic Activation means that the service is not necessary to be running in advance. When any message is received by the service it then launches and fulfills the request. But in case of self hosting the service should always be running.

Thanks and Regards
Akiii
WCF processes messages in buffered mode. True or False ?

NOTE: This is objective type question, Please click question title for correct answer.
Which transferMode is the default transferMode in WCF ?

NOTE: This is objective type question, Please click question title for correct answer.
Can we propagate CLR Exception across service boundaries in WCF ?

No, we cannot propagate CLR Exceptions across service boundaries.

If you want to propagate exception details to the clients then it can be done through "FaultContract " attribute. This way a custom exception is being passed to the client.



Thanks and Regards
Akiii
In WCF, what happens if there is an unhandled exception ?

The service model returns a generic SOAP fault to the client which does not include any exception specific details by default. However, an exception details in SOAP faults can be included using 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.

IncludeExceptionDetailsInFaults can be enabled in the web.config file :-

<behaviors>

<serviceBehaviors>
<behavior name="ServiceGatewayBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>




Thanks and Regards
Akiii
Are SOAP faults inter-operable ?

Yes, SOAP faults are inter-operable as they are expressed to clients in XML form.

.Net exception classes are not good to be used in SOAP faults. Instead we should define our own DataContract class and then use it in a FaultContract.

public interface ICalculator

{
[OperationContract]
[FaultContract(typeof(MathFault))]
int Divide(int n1, int n2);
}


[DataContract]

public class MathFault
{
[DataMember]
private string operation { get; set; }
[DataMember]
private string problemType { get; set; }
}


public int Divide(int n1, int n2)

{
try
{
return n1 / n2;
}
catch (DivideByZeroException)
{
MathFault objMath = new MathFault();
objMath.operation = "division";
objMath.problemType = "divide by zero";
throw new FaultException<MathFault>(objMath);
}
}


Thanks and Regards
Akiii
What is a proxy class for WCF Service ?

It is a class by which a service client can interact with the service. The client will make an object of the proxy class and by the help of it will call different methods exposed by the service.



Thanks and Regards
Akiii
State which one is the odd one out in case of SOAP(Simple Object Access Protocol) Message format.

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories