Automatic Format Selection in WCF RESTful service

By | February 17, 2014

In .NET framework 4.0, Automatic Format Selection feature is introduced by AutomaticFormatSelectionEnabled property of WebHttpBehavior class. The purpose is to dynamically find out and return the response in appropriate format for a service operation.MCSD Exam: 70-487
If the value of this property is set to “true” means using Automatic Format Selection, the response format of the operation is determined by the following factors in the same ordered way:

  1. Accept header of Request Message
  2. Content-Type of the HTTP request Message
  3. ResponseFormat parameter of service operation.
  4. WebHttpBehavior’s default format settings

WCF RESTful Service
By default, AutomaticFormatSelectionEnabled property of WebHttpBehavior class is set to false. So, in my previous article on Step by step creating a WCF RESTful Service, we explicitly defined format selection of ResponseFormat parameter in Web operation as follows:

    public interface IProductRESTService
        [WebInvoke(Method = “GET”,
                                 ResponseFormat = WebMessageFormat.Xml,
                                 BodyStyle = WebMessageBodyStyle.Bare,
                                 UriTemplate = “GetProductList/”)]
        List GetProductList();

But when Automatic Format Selection feature is enabled, Accept header of request message takes the highest precedence. First of all, Windows Communication Foundation infrastructure looks for Accept header of Request message. If found an appropriate format, response will be returned in the same format. However, if not the value of Accept header is found suitable, then WCF will look for the next factor i.e. Content Type of Request Message.

In one of my WCF service tutorial, I have explained how to consume WCF RESTful service using jQuery? So, if you wanted to see that how to set media-type of Accept header or Content-Type of request message, you can find complete code in that WCF RESTful Service Example. For your understanding, following is the sample jQuery Ajax call for my WCF HTTP Service.

                 type: “GET”,
                 url: “http://localhost/XXXXXXX/XXX”,
                 dataType: “json”,
                 contentType: “json”,
                 success: function (data) {
//Success code…                     
                 error: function (xhr) {

In above jQuery code snippet, dataType represents the expected response format from server that becomes the value of Accept header in Request Message, while contentType is Content Type of the same.

So, in order, if no appropriate Content Type is specified, ResponseFormat parameter in WebInvokeAttribute/WebGetAttribute of service operation will be considered, already explained above.
Lastly, DefaultOutgoingResponseFormat property of WebHttpBehavior class will be used to determine the output format of WCF RESTful service response, if nothing found in service operation attribute.

Now, how to enable this Automatic Format Selection feature for a WCF RESTful service? It can be done programmatically as well as through configuration. Configuration settings for enabling this feature is simple and straight forward using:

  • WebHttpBehavior
  • WebHttpEndpoint

Using WebHttpBehavior:-

            <service name=”MyRESTService.ProductRESTService” behaviorConfiguration=”serviceBehavior”>
                <endpoint address=””
                               contract=”MyRESTService.IProductRESTService” behaviorConfiguration=”web”>
                <behavior name=”serviceBehavior”>
                    <serviceMetadata httpGetEnabled=”true”/>
                    <serviceDebug includeExceptionDetailInFaults=”false”/>
                <behavior name=”web”>
                    <webHttp automaticFormatSelectionEnabled=”true” />
        <serviceHostingEnvironment multipleSiteBindingsEnabled=”true” />

Using WebHttpEndpoint:-

                    <standardEndpoint name=”web”
 automaticFormatSelectionEnabled=”true”  />

Hopefully, this WCF tutorial has simplified the concept of Automatic Format Selection for Windows Communication Foundation RESTful service.

Recents WCF Jobs in USA

Dot Net Developer(F2F)
Source: Indeed
Details: Experience developing framework components and web services • Experience in WCF Services development. C# 7+, JavaScript 5+, HTML 5+, SQL 5+, Unit testing (nunit...  More
10 days ago

Overland Park, KS 66210 19-May-2017

Dot Net Developer
Source: Indeed
Details: Hello Hope you are doing great. Job Title : .Net Developer Location : Dallas,TX (F2F is Mandatory) Rate : $40/hr On C2H We need GC and USC . Please don't  More
11 days ago

Dallas, TX 18-May-2017

Senior .Net Developer
Source: Indeed
Details: Experience in .NET web services, WCF, WPF and applications. Face to Face Mandatory*....  More
5 days ago

Chicago, IL 24-May-2017

.Net Architect / Sr. Developer
Source: Comtech LLC
Details: Experience with Web API and REST, WCF, LINQ, and MVC preferred (2+ year). Summary of Key Responsibilities....  More
5 days ago

Seattle, WA 25-May-2017

.Net Architect / Sr. .NET Developer
Source: Comtech LLC
Details: Experience with Web API and REST, WCF, LINQ, and MVC preferred (2+ year). Summary of Key Responsibilities....  More
5 days ago

Seattle, WA 25-May-2017

.Net Developer
Source: Speridian
Details: Primary Technology skills with expertise level 8+ (out of 10) needed are C#,, Web API, WCF, SQL DB, Web services, OAuth 2.0, JIRA, Bit Bucket, TFS, MSMQ...  More
19 days ago

Seattle, WA 11-May-2017

C# / ASP.NET Developer (FTE) (Dallas)
Source: Brand Protection Agency, LLC
Details: The developer will be exposed to the latest technologies such as WCF, ASP.NET, ASP.NET MVC, .NET 3.5 and 4.0, JavaScript, AJAX, JSON, ext-js and other open...  More
18 hours ago

Dallas, TX 29-May-2017

.NET Principal Software Engineer, NLP Department
Source: UnitedHealth Group
Details: WCF and/or Web Services. Combine two of the fastest-growing fields on the planet with a culture of performance, collaboration and opportunity and this is what...  More
30+ days ago

San Diego, CA 27-April-2017

.NET Developer - FTE
Source: Intertech, Inc.
Details: An understanding and knowledge of .Net, Web Services, WPF, WCF, MVC, Patterns/OO Design, and Web Frameworks....  More
3 days ago

Eagan, MN 27-May-2017

Technical Integration .NET Developer
Source: Campus Management
Details: Solid knowledge of .Net framework 4.0 or higher, C#, ASP.NET, WCF Web Services, Windows Workflow, Visual Studio 2013, SOA, Web Services, XML/XSL, AngularJS,...  More
4 days ago

Boca Raton, FL 33431 26-May-2017

Sr. .NET Developer (C#, ASP, WCF Services) - FAA
Source: Engility Corporation
Details: 5 years or more experience with C#, WCF Services, MVC 4.0 or higher, Linq, Entity Frame work. .Net development experience in C#, ASP.NET and WCF Services using...  More
30+ days ago

Washington, DC 24-March-2017

.NET Developer
Source: Bank of America
Details: WCF. Develop core credit and banking software solutions for the Global Wealth Management business and clients, Analyze business and technical requirements,...  More
30+ days ago

Pennington, NJ 08534 24-March-2017

.Net Developer
Source: SkillDemand
Details: Proficient in C# .NET, Entity Framework, MVC 4 or MVC 5, jQuery, JavaScript, LINQ, WCF Services Web API 2.0 Web Services (RESTful)....  More
5 days ago

Indianapolis, IN 25-May-2017

ASP .Net WPF & C# Developer
Source: Diverse Lynx LLC
Details: Job Description Role : ASP .Net WPF & C# Developer Work Location : Orlando,FL Emp Type : Permanent Job Interview : Phone/Skype Mandatory Technical /  More
5 days ago

Orlando, FL 25-May-2017

.Net Developer
Source: Pragmatics
Details: Expert Knowledge of WCF, REST,SOAP and JSON is required. The .Net Developer will develop full stack solutions for our internal and client-facing web...  More
30+ days ago

Washington, DC 07-April-2017

Sr. .NET and SharePoint Developer
Source: Visa
Details: Experience building web services/APIs using WCF and Web API. Visa's Collaboration Technologies team is looking for curious, creative, and talented technologists...  More
6 days ago

Austin, TX 24-May-2017

.NET C# WPF Developer
Source: PruTech Solutions
Details: Experience working using WCF. Front office developer required to continue build of Commodities desktop platform for Commodities traders and other business users...  More
6 days ago

North Brunswick, NJ 23-May-2017

Sitecore CERTIFIED .Net Developer
Source: Pet Supplies Plus
Details: Design and develop n-tier .NET MVC web applications, WCF Services, WPF applications, web APIs and web services, windows services and console applications using...  More
6 days ago

Livonia, MI 48152 23-May-2017

.Net Developer (WCF Services, MVC 4.0, Entity 5.0 framework expertise)
Source: Leidos
Details: 5 years or more experience with C#, WCF Services, MVC 4.0 or higher, Linq, Entity Frame work. .Net development experience in C#, ASP.NET and WCF Services using...  More
30+ days ago

Washington, DC 20001 18-March-2017

.Net Developer, Staff
Source: Fiserv
Details: Must be able to demonstrate knowledge of WCF architecture and configuration. 3 Type of work experience required Minimum of 3+ years of MS .Net experience...  More
6 days ago

Dublin, OH 23-May-2017

.NET Software Developer - Mid to Sr. Level
Source: Keefe Groupe
Details: ASP .NET OR Web Services / WCF a plus. Keefe Group, through its affiliates, Keefe Supply, Keefe Commissary Network, Crawford Supply, Access Catalog, Access...  More
6 days ago

Missouri 23-May-2017

.NET Developer
Source: Resolvit, LLC
Details: Knowledge of WCF and ASP.NET Web APIs. Bringing Solutions That Make Business Better....  More
7 days ago

Gaithersburg, MD 23-May-2017

.Net Developer
Source: exp
Details: Builds new systems with .NET (mainly C# and ASP.NET), WCF Data Services, MSSQL Server, Oracle, and SOA technologies....  More
7 days ago

Chicago, IL 22-May-2017

Sr .Net developer
Source: Spruce Infotech Inc
Details: Job Description Hi, Please find the below Role & Share suitable profiles. Title/Job: Senior .Net Web Developer Location: Harrisburg, PA Duration: Around 7...  More
18 days ago

Harrisburg, PA 12-May-2017

.NET Developer
Source: Empirical Edge
Details: Knowledge or Exposure to WPF, WCF, LINQ ,RAD controls & Silverlight will be added advantage. 2+ Years of Experience (for multiple positions)....  More
8 days ago

Marlton, NJ 08053 22-May-2017
Category: C# RESTful API WCF RESTful Service Tags: ,


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,, and

  • anish mounish

    This comment has been removed by a blog administrator.