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

C#/.NET Software Engineer
Source: Indeed
Details: WCF, WPF, SQL, VSTS, GIT, HTML, CSS, scripting, XML, JSON, IIS, and build systems, and Windows services. Covestic is looking for a C#.Net Software Engineer that...  More
30+ days ago

Seattle, WA 23-June-2017

Senior Software Engineer (C# / .NET)
Source: Corus Group, LLC
Details: The ideal candidate will have Web Services, WCF, enterprise design patterns, Advanced SQL, test framework expertise for writing unit tests for coverage (MSTest...  More
10 days ago

Los Angeles, CA 15-July-2017

Senior C#/.Net Developer
Source: Indeed
Details: WCF, WPF, SQL, VSTS, GIT, HTML, CSS, scripting, XML, JSON, IIS, and build systems, and Windows services. Local Candidates only must live in Seattle, WA*....  More
14 days ago

Seattle, WA 11-July-2017

Automation Developer
Source: Payoneer
Details: At least 3 years of experience in .NET, C# (MVC, WCF, WEB API). Automation Developer, New York....  More
14 days ago

New York, NY 10023 11-July-2017

Senior C#/.Net Developer
Source: Indeed
Details: *Quest Diagnostics (NYSE: DGX) is currently seeking a Senior C#/.Net Developer to work with our team on-site in Lenexa, KS.* The Senior C#/.Net Developer is...  More
13 days ago

Lenexa, KS 12-July-2017

Source: Indeed
10 days ago

Plano, TX 15-July-2017

Software Development Engineer in Test
Source: Pactera
Details: Utilizes Agile software development methodologies to manage design and development of test plans, scenarios, cases, reports and documentation for manual and...  More
28 days ago

Redmond, WA 27-June-2017

Developer, Database & Web
Source: Knorr-Bremse North America
Details: Expert with HTML, DHTML, XML, CSS, JavaScript, AJAX library and ASP.NET AJAX control toolkit, ASP.NET, WebServices and script services(asmx, wcf)....  More
10 days ago

Irvine, CA 15-July-2017

Development Manager
Source: Veros
Details: Visual Studio, ASP.NET, C#, WCF and IIS. Reporting to the Director, Software Development, this position will take principal responsibility for oversight of much...  More
4 days ago

Santa Ana, CA 21-July-2017

Tech Analyst (Application Development)
Source: Bank of America
Details: Job Description: **Candidates requiring visa sponsorship will not be considered for this position** Enterprise Role Overview: This role is specific to  More
19 hours ago

Plano, TX 75024 25-July-2017

Front End Developer - Web Services, C#
Source: Advantech
Details: Web services, C#, WebAPI, WCF, MVC, SQL Server, SSRS, NUnit or MSTest. We are looking for a Front End Developer with experience developing or architecting...  More
30 days ago

Houston, TX 77002 25-June-2017

Mid Level .Net with Azure
Source: Indeed
Details: Web Services – WCF, REST, Web APIs (At least one) *. At least 5 years of Experience working in .NET, C#, MVC applications with specific exposure to .Net...  More
14 days ago

Redmond, WA 11-July-2017

Software Developer Co-op
Source: Bastian Solutions
Details: Technologies include WPF, WCF, ASP.NET, JQuery. Seeking creative, talented, up and coming developers who are eager to learn, enjoy challenges, and looking to...  More
6 days ago

Louisville, KY 40223 19-July-2017

Junior Quality Analyst
Source: Indeed
Details: NET development (ASP.NET, C#, VB.NET, WCF) including .NET frameworks. Looking for someone with a Software Testing QA / Product Support background with product...  More
5 days ago

Omaha, NE 20-July-2017

Source: Bank of America
Details: Working knowledge of Microsoft.Net Framework 4.0 or higher with proficiency in C# and WCF services. Fiddler, Firebug, Poster, IE Developer Tools....  More
30+ days ago

Pennington, NJ 08534 13-April-2017

Application Programmer
Source: Bank of America
Details: C# WCF Services Programming & XML Processing. Develops, enhances, debugs, supports, maintains and tests software applications that support business units or...  More
25 days ago

Plano, TX 75024 30-June-2017

Application Developer
Source: Bank of America
Details: 5+ years - Expert knowledge of .Net, MVC , Visual Studio, ASP .net 4.5, WCF, Web APi, SQL server 2012, TFS, ADA , XML, XSL, Telerik,3 application frameworks,...  More
4 days ago

Plano, TX 75024 21-July-2017

Jr .Net Developer
Source: Indeed
Details: 5+ years of solid web application development skills utilizing .NET framework 4.0, C#, ASP.NET, Java Script, HTML, XML, Web Services, WCF, JQuery....  More
2 hours ago

Minneapolis, MN 25-July-2017

Hybrid Mobile Web Developer
Source: XDuce
Details: Expert knowledge of the Microsoft technologies, including .NET, ASP.NET, MVC, MS SQL Server, WCF. Hybrid Mobile Web Developer....  More
21 days ago

New York, NY 04-July-2017

GE Proficy Developers (10 positions) || Cincinnati OH
Source: Indeed
Details: *Hello,* *Hope you are fine!* *Profile* Developer/Deployment Support *Work Location* Cincinnati, OH *# of Requirements* 10 *Job Title* Programmer ...  More
8 hours ago

Plainsboro, NJ 25-July-2017

Junior Software Engineer
Source: Indeed
Details: C#, SQL server, T-SQL, writing queries, data modeling, and WCF service. Cobb Systems Group is seeking candidates for a *Junior Software Engineer*....  More
26 days ago

New York, NY 29-June-2017

Front End .NET Software Engineer
Source: All Web Leads
Details: Experience building and consuming web services (SOAP, REST, WCF, IIS, XML, JSON). Just named Austin Business Journal's 2017 Best Places to Work - #4 in Large...  More
14 days ago

Austin, TX 78730 11-July-2017

Senior Software Engineer
Source: LogixHealth
Details: Strong working knowledge in HTML, CSS, AJAX, SQL Server including stored procedure programming, and ASP .NET, JQuery, C# programming, MVC3/4/5, WCF, MVVM...  More
25 days ago

Bedford, MA 01730 30-June-2017

Lead Software Developer
Source: Interstates
Details: Design, develop, and implement software using primarily the Microsoft stack of technologies, including C#, WPF, MVC, WCF, and Microsoft SQL Server....  More
25 days ago

Sioux Falls, SD 30-June-2017

Lead Software Developer
Source: Interstates
Details: Design, develop, and implement software using primarily the Microsoft stack of technologies, including C#, WPF, MVC, WCF, and Microsoft SQL Server....  More
25 days ago

Sioux Center, IA 30-June-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.