What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 28875 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > WCF Interview Questions

Now you don't need go anywhere to get the best interview questions on Microsoft technology. We are trying to gather all real interview questions asked from MNCs and put them here. You can also assist us in doing so by submitting .net interview questions. These questions are generally different from certification questions however it may help you in that too.



Page copy protected against web site content infringement by Copyscape
NOTE: This is objective type question, Please click question title for correct answer.

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

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

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

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

NOTE: This is objective type question, Please click question title for correct answer.

Simplex - Also known as one way communication. Source will send a message to the target, but target will not respond to the message.

Request/Replay - It is two way communications, source send message to the target, target will resend the response message to the source. But in this scenario at a time only one can send a message (that is), either source or destination.

Duplex -Also known as two way communication, both source and target can send and receive message simultaneously.



Thanks and Regards
Akiii

[MessageContract]

public class EmployeeDetails
{
[MessageHeader]
public int ID;

[MessageBodyMember]
public string First_Name;

[MessageBodyMember]
public string Last_Name;
}


Message contract can be applied to type using MessageContract attribute as shown above. We can add custom header and custom body by using MessageHeader and MessageBodyMember attribute respectively.

When EmployeeDetails type in the service operation is used as parameter then WCF will add an extra header call 'ID' to the SOAP envelope. It also add First_Name, Last_Name as an extra member to the SOAP Body.



Thanks and Regards
Akiii

When we need a higher level of control over the message, such as sending custom SOAP header, then we can use MessageContract instead of DataContract . But in general cases, most of the messaging needs can be fulfilled by DataContracts.




Thanks and Regards
Akiii

(1) Inter-operability with applications built on differnet technologies.

(2) Unification of the original Dotnet Framework communication Technologies.

(3) Support for Service Oriented Architecture (SOA).



Thanks and Regards
Akiii

Web Service (that is), ASMX will be the most likely way to achieve cross-vender inter-operability.



Thanks and Regards
Akiii

NOTE: This is objective type question, Please click question title for correct answer.

The three components that a WCF must implement are :-

(1) Service Class = This can be implementated in any dotnet language. It implements one or more methods.

(2) Host Process = A process in which the service will run.

(3) End-Points = One or more end-points are provided that allow the clients to access the service.



Thanks and Regards
Akiii

NOTE: This is objective type question, Please click question title for correct answer.

If you do not specify "[OperationContract] " in any of the methods in your interface then you will get the following error :-

IService1' has zero operations; a contract must have at least one operation 



Here, Iservice is the name of my Interface. you can have your own name.
So, it is mandatory to label "[OperationContract] " attribute to at least one method while declaring your interface methods or ServiceContract.



Thanks and Regards
Akiii

Found this useful, bookmark this page link to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape
Navigate to Page: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

 More Exclusive WCF Interview Questions and Answers here


Found interesting? Add this to:


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 5:10:19 PM