WCF RESTful Service      Interview Questions         WCF Bindings             WCF Tracing                              

Monday, August 27, 2012

Difference between BasicHttpBinding and WsHttpBinding

Microsoft Windows Communication Foundation comes with a set of built-in bindings and each binding is designed to fulfill some specific need. So, if interoperability is our concern and we need to communicate with non-WCF system, then, we should go for basicHttpBinding or wsHttpBinding. Although these two bindings can work with WCF specific systems as well. But there are many differences between the two bindings. 

Following table explains the difference between BasicHttpBinding and WsHttpBinding.


BasicHttpBinding
WsHttpBinding
1
Primarily BasicHttpBinding is designed to exchange SOAP over HTTP(s) only, just like old ASMX or .net web services and supports the WS-I BasicProfile.

WsHttpBinding supports the advanced WS-* specification which includes WS-Addressing and WS-Security etc.
2
It has higher level of interoperability with existing services and clients.
Due to more advanced messaging scenarios, it has reduced support for wider range of older clients.
3
BasicHttpBinding is based on SOAP 1.1 specification.
WsHttpBinding supports SOAP 1.2 specification.
4
No support for reliable Messaging.
Supports for reliable messaging.
5
No support for transactions.
It supports atomic and distributed transactions.
6
It has fewer security options. Or we can say, there is no security provided, by default, for BasicHttpBinding.
Because 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.
7
At transport level, it provides support for confidentiality through SSL.
It supports for both Transport as well as Message level security.
8
BasicHttpBinding is a bit faster because security is disabled by default.
As it supports advanced security options and its enabled by default, so it’s a bit slower than BasicHttpBinding.


Be social and share with others via:


.NET Jobs from Indeed
Reader of this article might also be interested in:

By Imran Abdul Ghani
Software Developer (Senior)
United Arab Emirates
Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net & www.topwcftutorials.net.

Monday, August 13, 2012

WCF Service or ASP.NET Web APIs?

Few days back, while going through a technical forum, I read the following..
"Why do we need WCF now? We can go for new ASP.NET Web APIs framework".

Actually, Windows Communication Foundation is designed to exchange SOAP-based messages using variety of transport protocols like HTTP, TCP, NamedPipes or MSMQ etc. While ASP.NET API is a framework for building non-SOAP based services over HTTP only.

Understanding the difference between the two technologies is the real purpose of this WCF Tutorial. This is a misconception about ASP.NET Web API framework that its going to replace WCF. Its just another way of building services that are non-SOAP based e.g. plain XML, JSON string etc. Also it has following advantages as:
  • It allows us to create resource-oriented services using full features of HTTP.
  • Exposing services to variety of clients easily like browsers, mobile devices etc.

WCF is still the best choice for:
  • Messag Queuing scenario using MSMQ.
  • One-way communication or Duplex communication
  • If we intended to use transport other than HTTP e.g. TCP, UDP or Named Pipes.


Be social and share with others via:


.NET Jobs from Indeed
Reader of this article might also be interested in:

By Imran Abdul Ghani
Software Developer (Senior)
United Arab Emirates
Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net & www.topwcftutorials.net.

Tuesday, August 7, 2012

Visual Studio 2012 and .NET 4.5 will be available on 15 August

Microsoft Visual Studio 2012 and .NET framework 4.5 RTM build is complete and ready to go live on 15th August.

Microsoft announced that official launching of product is set on 15th August. "The engineering team is finished and is now preparing the build for our numerous distribution channels" by Microsoft representative.

 It will be available in four different flavors:
  • Visual Studio Professional
  • Visual Studio Premium
  • Visual Studio Test Professional
  • Visual Studio Ultimate
Let's see what's new exciting features for WCF 4.5 be part of final build. Already Microsoft published proposed features in WCF 4.5 list.
Reader of this article might also be interested in:

Imran Abdul Ghani
Software Developer (Senior)
United Arab Emirates
Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net & www.topwcftutorials.net.

Sunday, August 5, 2012

WCF Interview Questions - Part 1

This WCF Tutorial is a collection of most frequently asked interview questions about Windows Communication Foundation (WCF) covering the beginner to professional level.

What is WCF?
Microsoft refers WCF as a programming platform that is used to build Service-oriented applications. Windows Communication Foundation is basically a unified programming model for developing, configuring and deploying distributed services.  Microsoft has unified all its existing distributed application technologies (e.g. MS Enterprise Services, ASMX web services, MSMQ, .NET Remoting etc) at one platform i.e. WCF. Code name for WCF was Indigo.

Why to use WCF? or What are the advantages for using WCF?
  • Service Orientation is one of the key advantages of WCF. We can easily build service-oriented applications using WCF.
  • If compared with ASMX web services, WCF service provides reliability and security with simplicity.
  • As oppose to .NET Remoting, WCF services are interoperable.
  • Different clients can interact with same service using different communication mechanism. This is achieved by using service endpoints. A single WCF service can have multiple endpoints. So, developer will write code for service once and just by changing configuration (defining another service endpoint), it will be available for other clients as well.
  • Extensibility is another key advantage of WCF.  We can easily customize a service behavior if required.
What are the core components of WCF Service?
A WCF service has at least following core components.
  • Service Class:  A ervice class implementing in any CLR-based language and expose at least one method.
  • Hosting Environment: a managed process for running service.
  • Endpoint: a client uses it to communicate with service.
What is the difference between WCF and ASMX Web services?
The basic difference is that ASMX web service is designed to send and receive messages using SOAP over HTTP only. While WCF service can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, Named Pipes etc).
You can find detailed discussion on WCF Vs ASMX Web services here.

What are the Endpoints in WCF? or Explain ABCs of endpoint?
For WCF services to be consumed, it’s necessary that it must be exposed; Clients need information about service to communicate with it. This is where service endpoints play their role.
A service endpoint has three basic elements or also called ABCs of an endpoint i.e. Address, Binding and Contract.
Address: It defines “WHERE”. Address is the URL that identifies the location of the service.
Binding: It defines “HOW”. Binding defines how the service can be accessed.
Contract: It defines “WHAT”. Contract identifies what is exposed by the service.

What is a WCF Binding? How many different types of bindings available in WCF?
Bindings in WCF actually defines that how to communicate with the service. Binding specifies that what communication protocol as well as encoding method will be used. Optionally, binding can specify other important factors like transactions, reliable sessions and security.
Another WCF Tutorial gives more detailed understanding of Binding concept in WCF.

There are different built-in bindings available in WCF, each designed to fulfill some specific need.
  • basicHttpBinding
  • wsHttpBinding
  • netNamedPipeBinding
  • netTcpBinding
  • netPeerTcpBinding
  • netmsmqBinding
For details on different binding types, please follow the link to WCF bindings.

Can we have multiple endpoints for different binding types in order to serve different types of clients?
Yes, we can have multiple endpoints for different binding types. For example, an endpoint with wsHttpBinding and another one with netTcpBinging.

What are the hosting options for WCF Services? Explain.
For a service to host, we need at least a managed process, a ServiceHost instance and an Endpoint configured. Possible approaches for hosting a service are:
      1.    Hosting in a Managed Application/ Self Hosting
             a.    Console Application
             b.    Windows Application
             c.    Windows Service
        2.    Hosting on Web Server
             a.    IIS 6.0 (ASP.NET Application supports only HTTP)
             b.    Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP,
                    NamedPipes, MSMQ.

What are Contracts in WCF?
A Contract is basically an agreement between the two parties i.e. Service and Client. In WCF, Contracts can be categorized as behavioral or structural.
  1. Behavioral Contracts define that what operations client can perform on a service.
    • ServiceContract attribute is used to mark a type as Service contract that contains operations.
    • OperationContract attributes is used to mark the operations that will be exposed.
    • Fault Contract defines what errors are raised by the service being exposed.
  2. Structural Contracts
    • DataContract  attribute define types that will be moved between the parties.
    • MessageContract attribute define the structure of SOAP message.
What Message Exchange Patterns supported by WCF?
  •  Request/Response
  •  One Way
  •  Duplex
Request/Response
It’s the default pattern. In this pattern, a response message will always be generated to consumer when the operation is called, even with the void return type. In this scenario, response will have empty SOAP body.
One Way
In some cases, we are interested to send a message to service in order to execute certain business functionality but not interested in receiving anything back. OneWay MEP will work in such scenarios.If we want queued message delivery, OneWay is the only available option.
Duplex
The Duplex MEP is basically a two-way message channel. In some cases, we want to send a message to service to initiate some longer-running processing and require a notification back from service in order to confirm that the requested process has been completed.

Next WCF Tutorial on Interview Questions and Answers in this series is about Proxy and Channel Factory, Concurrency and Throttling in WCF.


Be social and share with others via:


.NET Jobs from Indeed
Reader of this article might also be interested in:

By Imran Abdul Ghani
Software Developer (Senior)
United Arab Emirates
Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net & www.topwcftutorials.net.