WCF Interview Questions – Part 3

By | October 16, 2012

This WCF tutorial is part-3 in series of WCF Interview Questions and Answers. Other parts in this series are as follows:

  1. WCF Service Interview Questions – Part 1
  2. WCF Service Interview Questions – Part 2
  3. WCF Service Interview Questions – Part 3
  4. WCF Service Interview Questions – Part 4

WCF Interview Questions List – Part 3

What is a fault contract?

Normally, by default, when some exception occurs at a WCF service level, it will not expose as it is to client. Reason is that WCF exception is a CLR exception and it doesn’t make sense to expose it outside CLR because it contains internal details of service code like stack trace. So, WCF handles and returns error details to client using Fault Contract.“So, fault contract is a contract that contains the details of possible exception(s) that might occur in a service code.WCF Fault

 [ServiceContract]
 public interface IService1
 {
        [OperationContract]
        [FaultContract(typeof(MyFaultDetails))]
        int MyOperation1();
 }
 [DataContract]
  public class MyFaultDetails
  {
        [DataMember]
        public string ErrorDetails { get; set; }
  }

In implementing service…..

  public int MyOperation1()
  {
       Try{               //Do something……       }catch()
       {
                  MyFaultDetails ex = new MyFaultDetails();
                  ex.ErrorDetails = “Specific error details here.“;
                  throw new FaultException(ex,“Reason: Testing…..“);
       }
  }

For understanding detailed difference between .NET Exception and WCF Fault, Click here.
Back to top

A user has a service with a one-way operation that includes a fault contract, and he gets an exception when he tries to host the service. Why?

This is true, because, to return faults, the service requires some form of a two-way communication channel, which is not there with one-way operations.
Back to top

What are the core security concepts supported by WCF?

There are four core security FeaturesWCF Security Concepts

  • Confidentiality: It’s a confirmation about the recipient. Only the valid recipient can read the message when it passed between service and client.
  • Integrity: is to ensure that message received is not being tempered or changed during exchange.
  • Authentication: is a way for the parties (sender and receiver) to identify each other.
  • Authorization: ensures that what actions an authenticated user can perform?

Back to top

Difference between Message Level security and Transport Level security?

Security can be configured at two different levels in Windows Communication Foundation:

  1. Transport Level Security
    secures the transport (the pipe) over which the message passes through from client to a service. 
  2. Message Level Security
    secures the message that is being transported from one end to another.

WCF Supports following Transfer Security Modes:

  • None – No security at all. Very risky to choose.
  • Transport – Securing message transfer with transport protocol like TCP, IPs, HTTPs, MSMQ.  It’s Ideal for Intranet scenarios having point to point communication.
  • Message – Securing message by encrypting it. Good for scenarios even when multiple intermediaries involved.
  • Mixed – TransportWithMessageCredential uses transport for message privacy and service authentication with client authentication handled at message level.
  • Both -Using both Message as well as transport security. In this case a secured encrypted message travel over a secure transport (pipe) only supported by MSMQ Binding.
<wsHttpBinding>
       <binding name=”SecurityModeDemo”>
                    <security mode=”[None|Transport|Message|….]”/>
       </binding>
</wsHttpBinding>

Details comparison of both Security Levels are given in other post Transport Level Security Vs Message Level Security.

Back to top

Can you please explain which security mode supported by various WCF Bindings?

Following table illustrates in details about support for security mode in Windows Communication Foundation for various WCF Bindings.

WCF Binding

None

Transport

Message

Mixed

Both

BasicHttpBinding Default Yes Yes Yes No
WSHttpBinding Yes Yes Default Yes No
WSDualHttpBinding Yes No Default Yes No
NetTcpBinding Yes Default Yes Yes No
NetNamedPipeBinding Yes Default No No No
NetMsmqBinding Yes Default Yes No Yes

Back to top

Difference between BasicHttpBinding and WsHttpBinding w.r.t Security?

WsHttpBinding supports advanced WS-* specification, it has a lot more security options available. For example, It provides message-level security i.e. message is not sent in plain text. Also it supports for WS-Trust and WS-Secure conversation.
While in case of BasicHttpBinding, it has fewer security options, or we can say, there is no security provided, by default. At transport level, it can provide confidentiality through SSL.

Following is detailed comparison of both WCF bindings:

basicHttpBinding Vs wsHttpBinding

Please follow differences between BasicHttpBinding and WsHttpBinding for more detailed.
Back to top

Please explain about authorization options supported in WCF?

Authorization as a core feature of security in WCF supports different authorization types.

  • Role-based authorization is the most common authorization approach being used. In this approach, authenticated user has assigned roles and system checks and verifies that either a specific assigned role can perform the operation requested.
  • Identity-based authorization approach basically provides support for identity model feature which is considered to be an extension to role-based authorization option. In this approach, service verifies client claims against authorization policies and accordingly grant or deny access to operation or resource.
    For more details on Authorization with Identity Model, please follow here.
  • Resource-based authorization approach is a bit different because it’s applied on individual resources and secure those using windows access control lists (ACLs).

Back to top

What is Reliable Messaging in WCF?

We know that networks are not perfect enough and those might drop signals or in some scenarios there can be a possibility of wrong order of messages during message exchange.
WCF allows us to ensure the reliability of messaging by implementing WS-ReliableMessaging protocol.  Here is how you can configure reliable messaging in WCF.

  <wsHttpBinding>
    <binding name=”Binding1″>
                  <reliableSession
                                         enabled=”true”
                                        ordered=”true”
                                        inactivityTimeout=”00:02:00″ />
     </binding>
  </wsHttpBinding>

Back to top

What are Reliable Sessions in WCF?

Reliable sessions actually ensure that the caller for messages will know about the lost message(s) but it can’t guarantee about the delivery of message(s).
There is a misconception about reliable sessions that it ensures the session will never expire or stays for a very long time. This we can achieve by using timeout for sessions.
Back to top

Briefly explain WCF RESTfull services?

RESTful services are those which follow the REST (Representational State Transfer) architectural style. As we know that WCF allows us to make calls and exchange messages using SOAP over a variety of protocols i.e. HTTP, TCP, NamedPipes and MSMQ etc. In a scenario, if we are using SOAP over HTTP, we are just utilizing HTTP as a transport. But Http is much more than just a transport. So When we talk about REST architectural style, it dictates that:

Instead of using complex mechanisms like CORBA, RPC or SOAP for communication, simply HTTP should be used for making calls

RESTful architecture uses HTTP for all CRUD operations like (Read/CREATE/Update/Delete) using simple HTTP verbs like (GET, POST, PUT, and DELETE). It’s simple as well as lightweight.WCF RESTful Service
For a practical example, you can follow 5 simple steps to create your first RESTful service.
Back to top

Explain the differences between SOAP and REST approaches w.r.t common CRUD operations?

For common CRUD(Create, Retrieve, Update, Delete) operations, both SOAP and REST approaches are different as follows:

CRUD Operation

RESTful approach

SOAP approach

Get Product By Id /product.svc/{id} (using GET HTTP Method) GetProduct(string id)
Get All Products /product.svc       (using GET HTTP Method) GetProducts()
Create Product /product.svc/{id}  (using PUT HTTP Method) CreateProduct(string id, string name)
Update Product /product.svc/{id}  (using PUT HTTP Method) UpdateProduct(string id)
Delete Product /product.svc/{id}  (using DELETE HTTP Method) DeleteProduct(string id)

Back to top

Briefly explain WCF Data Services?

WCF Data services previously known as ADO.NET data services are basically based on OData (Open Data Protocol) standard which is a REST (Representational State Transfer) protocol.WCF Data Services

 

You can follow here to understand and create your first WCF Data Service by using a step by step approach.

According to http://www.odata.org/

The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today. OData does this by applying and building upon Web technologies such as HTTP, Atom Publishing Protocol (AtomPub) and JSON to provide access to information from a variety of applications, services, and stores. The protocol emerged from experiences implementing AtomPub clients and servers in a variety of products over the past several years.  OData is being used to expose and access information from a variety of sources including, but not limited to, relational databases, file systems, content management systems and traditional Web sites.Next part in this WCF Tutorial series is focused on Interview Questions regarding Service-Oriented Architecture and Transactions.

Back to top

WCF Data Services Vs ASP.NET Web API OData?

WCF Data Services

ASP.NET Web API OData

Not truly Extensible. Truly Extensible.
Although it’s called WCF Data Services but it doesn’t required WCF Knowledge. Any HTTP Client (including PHP, JAVA, AJAX, WCF etc.) can consume WCF Data Services. Web API OData is added later to ASP.NET Web API and it’s basically a REST-based data access protocol.
Supports all OData Operations.  Not all OData Operations supported so far.
A bit complicated when using with non-LINQ provider data. Easier Programming Model.
Thorough and Complete implementation according to lastest OData Specification. As compared with data services, Web API OData gives better control over data sources.
We can expose whole data store with minimum logic. As it’s extensible, so it supports mixing OData with non-OData Services.

Back to top
Previous: WCF Service FAQs Part-2                                    Next: WCF Service FAQs Part-4

Top 10 Interview Questions and Answers Series:

Latest WCF and .NET Jobs in UAE [Updated Daily]

Top WCF Jobs

Consultant / Senior Consultant Technology - .NET
Source: Virtusa
Details: Design and development in .NET frameworks such as WF / WCF / WPF / Silverlight. Software Designing, Programming, Scripting, Analytical, Problem solving,...  More
8 days ago

UAE 17-July-2017

DOT NET DEVELOPER (WEB API)
Source: Nadia
Details: Responsible to develop the new applications using .Net technologies (Windows Forms, ASP .Net, WCF, WPF, WF, LINQ) from the initial stage and also participate in...  More
19 days ago

Dubai 06-July-2017

.NET Developer (Immediate joiners only)
Source: emaratech
Details: Webservices, WCF services & windows services. 5 - 7 years experience in C# .NET in an enterprise - oriented environment....  More
30+ days ago

Dubai 11-June-2017

Senior Software Developer
Source: Dotcom Systems
Details: C#, VB.net, SQL, Crystal Reports, HTML5, ASP.net, JQuery, ASP.net MVC, Oracle Database, Chrome Plug-in, Fire breath Framework, NHibernate, IIS Configuration,...  More
30+ days ago

Dubai 19-May-2017

SharePoint Developer cum Administrator
Source: Dotcom Systems
Details: Reference #: DOT1013-SPDA Position: SharePoint Developer cum Administrator Location: Dubai, UAE Skills Required: C#/VB.Net, SharePoint 2010, SQL 2008/2012  More
30+ days ago

Dubai 19-May-2017

Job Opening - Mobile Xamarin Developer - UAE
Source: monstergulf
Details: Hi, This is regarding an urgent job opening we have for our government sector client in UAE. Please find below the job description and if interested please...  More
10 hours ago

Abu Dhabi 25-July-2017

Dot Net Developer - Arabic
Source: Naukrigulf.com
Details: Position – .Net Developer - Arabic Location: Dubai Contract : 6 Months(Extendable) • .NET Framework 4.5 or above • WCF Services and extensibility • Oracle...  More
14 days ago

Dubai 11-July-2017

Tridion Experts – SDL Tridion – 12 Month Rolling Contract
Source: SwissGulf Partners
Details: Developing Web Applications using Web Services, WCF. Tridion Experts – SDL Tridion – 12 Month Rolling Contract – UAE....  More
13 days ago

UAE 12-July-2017

SharePoint Developer - MUST BE UAE BASED
Source: Michael Page AE
Details: Proficiency in technologies including C#, ASP.NET, XML and XSLT, WCF, AJAX, and SQL Server. Reporting to the Group IT Business Systems Manager the SharePoint...  More
30+ days ago

Dubai 23-May-2017

Engineer - Steelworks
Source: Fuschia Careers
Details: A premier Shipyard offering a comprehensive range of marine services as well as solutions for the oil and gas industry is actively seeking Engineers having 3  More
19 hours ago

UAE 25-July-2017

Foreman – Production Control (Boiler)
Source: Fuschia Careers
Details: A leading and world-class Shipyard in the Middle East is actively hiring professionals having enhanced machinery skills in Boiler works i.e. boiler mounting,  More
19 hours ago

UAE 25-July-2017

We Oppinig Detailed :: Xamarin Mobile Developer_Ajman_6Months (Maximum 1Year)
Source: Monster IN
Details: Full Command of Web Services and WCF. Mobile Developer (with experience not less than 5 years):....  More
10 hours ago

UAE 25-July-2017

Web Designer & Graphic Designer
Source: Indeed
Details: HTML, CSS, JavaScript, Advance JQuery, BootStrap, AngularJS, ASP.NET Web Forms, C#.NET, SQL Server, AJAX, Web Services, WCF and Windows Applications....  More
30+ days ago

Dubai 20-June-2017

Jr. Techno Functional and Support Consultant Dubai UAE
Source: Indeed
Details: IYCON is a transformational technology solutions company whose mission is to serve businesses and governments by delivering high quality strategic execution  More
22 days ago

Dubai Free Zone 03-July-2017

HRMS Implmenter / Consultant
Source: Indeed
Details: Good experience in Web services, WCF services, Windows Services, Asp.net MVC, JQuery, JqxGrid, JqGrid Libs and DevExpress Controls....  More
30+ days ago

Dubai 03-June-2017

.NET Developer / Dotnet Developer Umbraco Expert
Source: Indeed
Details: Experience of Agile methodologies Experience of service based development using technologies such as WCF, Web API and RESTful services....  More
2 days ago

Dubai 23-July-2017

Dotnet developer + Network Admin
Source: Indeed
Details: Coding using Asp.net, VB.Net, VB6, C#.net, MS SQL server 2008/2012 R2 (64 bit), Crystal report 13, Java script, Ajax, J Query, HTML, Web services, WCF, SOAP &...  More
26 days ago

Abu Dhabi 29-June-2017

Asp.net Developer
Source: Indeed
Details: SQL Server 2012 & onward, SQL Server Reporting Service (SSRS), WCF, Web Service etc. 3 years and above....  More
21 days ago

Dubai 04-July-2017

Senior Software Engineer
Source: Indeed
Details: WCF 4.0, WCF Rest; Designs and develops user interfaces to Internet/intranet applications by setting expectations and features priorities throughout development...  More
12 days ago

Dubai 13-July-2017

dot net developer network admin
Source: Indeed
Details: Coding using Asp.net, VB.Net, VB6, C#.net, MS SQL server 2008/2012 R2 (64 bit), Crystal report 13, Java script, Ajax, J Query, HTML, Web services, WCF, SOAP &...  More
20 days ago

Abu Dhabi 05-July-2017

Sitecore Developers (all levels)
Source: Mirum Agency
Details: NET, AJAX, WCF, JavaScript, Jquery, HTML, JS, CSS. We are looking for experienced developers to work on one of Dubai’s most prestigious brands....  More
30+ days ago

Dubai 11-June-2017

Software Developer
Source: Indeed
Details: We are urgently looking for a passionate computer programmer. The respective individual would be responsible for integrating our clients’ systems with our  More
30+ days ago

Abu Dhabi 11-June-2017

ASP.NET WEB FORM Developer
Source: Indeed
Details: ASP.NET WEB FORM ,.NET Design Patterns, Oracle DB, HTML 5, .NET, C# ,VB .Net,- Webservices-Programming, ADO.NET, and WCF Development, Desirable Skills:....  More
30+ days ago

Dubai 09-May-2017

Senior Software Developer (Microsoft .Net)
Source: Indeed
Details: *TATWEER* is a leading company that provides professional technical and management support and services for the planning, design, implementation, supervision,  More
30+ days ago

Dubai 27-April-2017

SOFTWARE DEVELOPER(QA)
Source: Indeed
Details: Practical knowledge using web services technologies and WCF. Key member of the R&D team creating and supporting the platform of software products & services....  More
30+ days ago

Sharjah 20-April-2017