WCF vs Web API, Deeper details?

Before I continue, I just want to mention I have heavily researched and searched on this topic, but I need the opinion of people who have worked/and or have practical knowledge with
regards to this topic.
We are currently looking at developing an API so that clients can utilize this. We are definitely set on REST as opposed to SOAP, but I am still a little unclear about what exactly the difference is, if you go down to microscopic detail.
Having a look at msdn (Choosing which technology to use), the link below:
http://msdn.microsoft.com/en-us/library/jj823172.aspx
The differences are clear. However, the first point states for WCF:
Enables building services that support multiple transport protocols (HTTP, TCP, UDP, and custom transports) and allows switching between them.
For ASP.NET Web Api:
HTTP only. First-class programming model for HTTP. More suitable for access from various browsers, mobile devices etc enabling wide reach.
So, both support HTTP, but WCF supports more protocols in addition. What makes ASP.NET Web API more suitable for, I quote: "More suitable for access from various browsers, mobile devices etc enabling wide reach." if both support HTTP?
We have until now, relied heavily on PC use. What I am getting to, and finally my question is:
We plan on going mobile, and moving a lot more to multiple devices, browsers etc. But I just would not like to go on a service on the basis of a bit of text saying "Web API" is more suitable? IS it more efficient, less resource intensive etc.? With
regards to future proofing? Would we be better of with WEB API and why? Just lastly, we have existing SOAP services, everything we have is built in SOAP.
Please do not hesitate to go into detail, I am not an experienced dev, just trying to add a contribution to this project.
Just a last couple of requirements:
1) We plan on utilizing JSON. 2) We are limited to .NET 3.5/4. 3) Must be REST.

Its all hype for the different products written by different product teams with incentive to get their baby adopted. Ignore them all and evaluate what you need, not what they need you to want.
What I do know if that ASP.NET projects require a heap of infrastructure (eg IIS, and associated configuration), whereas WCF can be built as stand-alone services that just run with minimal configuration (typically registering the root URL with http.sys).
This is the biggest win for me - recently we had some older ASP.NET projects that we had to integrate with, and what could have been an easy task with some WCF services was a huge PiTA as we had to go through a mass of setup instructions (that were not necessarily
up to date, of course) to get something working, not to mention the installation of system services to do this.
So you need to consider the future maintenance involved. If WebAPI requires a heap of setup, then I'd avoid it.
There are alternatives, WWS is much more efficient as WCF and supports the same protocols (not that it matters if you're only using HTTP). If you are just building a REST API then any web server, embedded or not, will do. (eg I added Mongoose to one of my
services recently, so now it serves http to clients as well, seamlessly and really simple though using C++ not C#).

Similar Messages

  • WCF and WP8.1: Can I only use WCF REST services? Then better WCF or Web API?

    I am trying to create a simple application to test WCF with WP8.1. I have created my service. Later I create my WP8.1 silver light application and I try to add a reference to my service Project. The problem is that I get an error that says that I have only
    add reference to projects that are Windows pone 8.
    I have read some solutions, but all of them are creating a WCF REST service, so my doubt if the WP8.1 applications only can connect to WCF REST services.
    In this case, if this is true, it not would be better to use Web API instead of WCF?
    Thanks so much.

    You can use any type of rest service with windows phone 8.1 because rest services can be called via the httpclient class.  You dont need a service reference.  Personally I prefer the web api but there is no reason you can not use a wcf rest service.

  • WCF Rest Service Vs Web API

    1. What is difference between WCF REST SERVICE(and not WCF) and WebAPI?
    2. When we should one over another?
    Deepak Talele Ph: 91-9158413830 Email: [email protected], [email protected]

    Hi,
    Use WCF to create reliable, secure web services that accessible over a variety of transports. Use ASP.NET Web API to create HTTP-based services that are accessible from a wide variety of clients. Use ASP.NET Web API if you are creating and designing new
    REST-style services. Although WCF provides some support for writing REST-style services, the support for REST in ASP.NET Web API is more complete and all future REST feature improvements will be made in ASP.NET Web API.
    For the difference between WCF REST Service and web api, you could refer to the following links for more information:
    https://msdn.microsoft.com/en-us/library/jj823172(v=vs.110).aspx
    http://www.dotnet-tricks.com/Tutorial/webapi/JI2X050413-Difference-between-WCF-and-Web-API-and-WCF-REST-and-Web-Service.html
    Regards

  • Beginner's questions about WCF and web services

    For the purpose of this forum let me just say that I got my certs back in Dot Net 2.0.  I know how to write simple web services.  Now someone has dumped a huge package of code on my desk that (I think) contains a WCF project (without documentation
    of course).  Contains references to System.ServiceModel.
    So my questions...
    1.  What (if anything) is the difference between WCF and Web API?
    2.  If there is a difference,  how do you decide which one to use?
     3.  Assuming that this project on my desk is a WCF project, where can I find some hints on how to run it in VS2013 Community? 

    WEB API is restricted to ASP.NET and HTTP. 
    http://captechconsulting.com/blog/john-nein/aspnet-web-api-vs-windows-communication-foundation-wcf
    WCF uses more communication protocols than just HTTP, there are more ways to host a WCF service other than IIS, like a selfhosting exe type WCF server,   and WCF is a SOA solution.
    WCF is a more robust solution in a whole lot of ways is the bottom line.
    http://en.wikipedia.org/wiki/Service-oriented_architecture
    http://www.codeproject.com/Articles/515253/Service-Oriented-Architecture-and-WCF

  • Trying to understand the various methods of the Office Web API

    Looking at the Office Web API, I don't see explanations, details of what a specific Office Web API method does. Is one suppose to experiment to discovered what they do, or is there some place I need to look for details?
    Thanks
    Jim

    ​Hi JimBassett,
    What do you mean by "Office Web API"? Do you mean javascript api for office? If so, I think you could turn to the link below for explanations, details of the methods.
    #JavaScript API for Office
    https://msdn.microsoft.com/en-us/library/office/fp142185.aspx
    If you mean the Office 365 API, here is a article for your reference:
    #Overview of developing on the Office 365 platform​
    https://msdn.microsoft.com/en-us/office/office365/howto/platform-development-overview
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Export data to excel with EPPlus and Web Api - HELP!

    I am trying to do a simple excel file export with EPPlus and Web Api. In the html client I have a button that calls the web api and opens a new window. No error is thrown, but the result is always "file could not be downloaded".  I get the
    save file dialog but the file name is Order/ instead of the expected Orders.xls or Orders.xlsx.  Can anyone help? I'm surprised this is so difficult.
    using System.Linq;
    using System.Net.Http;
    using System.Web.Http;
    using OfficeOpenXml;
    using System.Collections.Generic;
    using System.IO;
    using System.Net.Http.Headers;
    using System.Net;
    using System.ComponentModel.DataAnnotations;
    namespace LightSwitchApplication
    public class OrdersController : ApiController
    // GET: api/Orders
    [HttpGet]
    public HttpResponseMessage Get()
    HttpResponseMessage response;
    response = Request.CreateResponse(HttpStatusCode.OK);
    MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/octet-stream");
    response.Content = new StreamContent(GetExcelSheet());
    response.Content.Headers.ContentType = mediaType;
    response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
    response.Content.Headers.ContentDisposition.FileName = "Orders.xls";
    return response;
    public List<Order> GetOrders()
    List<Order> colOrders = new List<Order>();
    using (ServerApplicationContext ctx = ServerApplicationContext.Current ??
    ServerApplicationContext.CreateContext())
    colOrders = ctx.DataWorkspace.Data.Orders.GetQuery().Execute().ToList();
    return colOrders;
    public MemoryStream GetExcelSheet()
    using (var package = new ExcelPackage())
    var worksheet = package.Workbook.Worksheets.Add("Orders");
    worksheet.Cells["A1"].LoadFromCollection(GetOrders(), false);
    package.Save();
    var stream = new MemoryStream(package.GetAsByteArray());
    return stream;
    This has been driving me crazy for two days!

    Making some progress.  I got the spreadsheet into a byte[] and used code from Paul Van
    Bladel's blog to make the HttpResponseMessage.  If I comment out the LightSwitch data access code, this works to export a spreadsheet from a static list to the browser from Web Api.
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Web.Http;
    using Microsoft.LightSwitch;
    using Microsoft.LightSwitch.Details;
    using OfficeOpenXml;
    using System.ComponentModel.DataAnnotations;
    namespace LightSwitchApplication
    public class Order
    [Key]
    public int Id { get; set; }
    public string OrderNumber { get; set; }
    public class OrdersController : ApiController
    // GET: api/Orders
    [HttpGet]
    public HttpResponseMessage Download()
    MediaTypeHeaderValue mediaType =
    MediaTypeHeaderValue.Parse("application/octet-stream");
    byte[] excelFile = ExcelSheet();
    string fileName = "Orders.xlsx";
    MemoryStream memoryStream = new MemoryStream(excelFile);
    HttpResponseMessage response =
    response = Request.CreateResponse(HttpStatusCode.OK);
    response.Content = new StreamContent(memoryStream);
    response.Content.Headers.ContentType = mediaType;
    response.Content.Headers.ContentDisposition =
    new ContentDispositionHeaderValue("fileName") { FileName = fileName };
    return response;
    public List<Order> Orders()
    List<Order> orders = new List<Order>();
    orders.Add(new Order { Id = 1, OrderNumber = "123456789" });
    orders.Add(new Order { Id = 2, OrderNumber = "987654321" });
    return orders;
    // this doesn't work
    //public List<Order> Orders()
    // List<Order> colOrders = new List<Order>();
    // using (ServerApplicationContext ctx = ServerApplicationContext.Current ??
    // ServerApplicationContext.CreateContext())
    // colOrders = ctx.DataWorkspace.Data.Orders.GetQuery().Execute().ToList();
    // return colOrders;
    public byte[] ExcelSheet()
    using (var package = new ExcelPackage())
    var worksheet = package.Workbook.Worksheets.Add("Orders");
    worksheet.Cells["A1"].LoadFromCollection(Orders(), false);
    byte[] bytes = package.GetAsByteArray();
    return bytes;
    The problem is that the LightSwitch query (commented out in the code above) is trying to load navigation properties for the orders.  Error: "It is not valid to access this object on the current thread."  How do I solve this? 

  • MVC Web API in SharePoint site

    We're planning on moving most of our web presence on our SharePoint 2013 server in cloud. Our current setup uses a MVC Web API for data retrieval from DB. We do not want to host the API under a separate domain and thus need to move the API under SharePoint
    domain as well. There is no relaxation in this requirement.
    Is there a way to publish my API to SharePoint? Or is there a SharePoint specific API project template in Visual Studio? If not what are my options?

    Hi,
    According to your description, you might want to host the Web API in your SharePoint Online environment.
    If it is SharePoint Online, as we can’t access the backend server, your requirement might not be achievable at this moment.
    Your requirement is retrieving data from a database, as a workaround, you can use “the Business Connectivity Services (BCS) hybrid scenario to access on-premises data
    through SharePoint Online”:
    http://technet.microsoft.com/en-us/library/dn197239(v=office.15).aspx
    With the retrieved data from the database, you can create an External list, then access the data of this External list using Client Object Model.
    Or we can use an Azure SQL Server to sync with your database, then implement a Provider Hosted app to deal with the data from Azure SQL Server. The demo below would
    provide more details about this solution:
    http://blogs.msdn.com/b/alimaz/archive/2014/07/31/connect-sharepoint-online-to-an-on-premises-sql-server-from-an-azure-provider-hosted-app-using-hybrid-connections.aspx
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to exposing orchestration as web api ?

    Hi ALL,
          I have created Orchestration ,I want to Exposing my orchestration and Schema as a WEB API
    . Please help me to find the solution for this.
    Thanks in Advance !!!!!!!!!!!!!!!!!!!!!!!!
    Thanks and Regards
    Dhanavel

    Hi,
    As suggested by La Cour you can use WCF Publishing Wizard and publish your orchestration and schemas as REST Endpoint.
    Refer link: 
    http://seroter.wordpress.com/2012/11/12/exploring-rest-capabilities-of-biztalk-server-2013-part-1-exposing-rest-endpoints/
    Rachit

  • Web API Reference 7.0

    Hi,
    Anybody came across a Web API Reference for 7.0 as it is existing for 3.5?
    Although the new WAD ist much more intuitive, i really liked the detailed description of parameters etc....
    Thanks,
    Beat

    There isn't a similar web api type environment as you're not concatenating things into the URL to build custom buttons.
    In the online help, it explains that this is replaced with the command wizard and the javascript API
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/efcc6f2480025ae10000000a1553f7/frameset.htm
    The parameters from the command wizard are explained here:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/71/8a784226d1d242e10000000a1550b0/content.htm

  • Why is there no WSDL type support for Web Api?

    So I am just getting started with .Net WebApi and one thing that I am noticing straight away is that there is no Contract defining how the Api looks and should be consumed (Request/Responses from each Action), this is usually in the form of a WSDL for WCF/Soap.
    It seems to me like this is something that would be very valuable and make life a lot easier for consumers of your Api.
    Is there a reason there isn't one? Is there a programming paradime or principle that I am unaware of? Is there a way I could create one?

    SOAP, REST AND PEOPLE'S CREATIVITY
    SOAP needs a description document like WSDL because each resource can be consumed with different messages, there are no definition on the protocol about constraints to the possible names/messages that you can manipulate a resource.
    For example, in SOAP your web service that allow clients manipulate an user can expose the operation that create an user in many different messages, like:
    addUser
    createUser
    insertUser
    Of course, these are just few sample messages, because I've see a lot of funny web services method names. There are really creative people out there.
    In other hand, if you are exposing your underlying system using web api that really respect the REST principles, the client just need to know that you have a resource named Users, because there is 99% of chance that you can create an user in this way
    POST /Users
    And this occurs for each operation you want to expose using SOAP or a web api REST.
    Despite being SOAP a protocol, which restricts what you can or can not do, and be REST a style architecture, which leaves many open points of how to do things. There are efforts to define conventions of how to expose and consume REST web apis.
    DESCRIBING A WEB API REST
    In the field of how to describe a web api REST I can cite
    Swagger. It is not a attempt to create a WSDL like to web api REST, but it is a good attempt to create an open standard for describing web apis REST.
    Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services.
    I use Swagger a lot and really love it, mainly because
    Swagger UI that allow you generate a nice live console and documentation for your web api.
    There are many implementations of Swagger for most of languages: C#, Java, Python, Ruby, etc.
    If you are using ASP .NET Web API, there a some projects to auto generate the Swagger specification, like
    Swagger.NET
    GENERATING CLIENTS TO A WEB API REST
    Because the constraints of REST, like the limited set of verbs (GET, POST, PUT, DELETE, etc) is not so difficuty to generate a client library to a web api REST.
    Projects like
    WebApiProxy can easily generate clients do C# and Javascript.
    CONVENTIONS FOR WEB API REST
    To keep our lifes as developers easier is good define some conventions of how our web api REST will behave, the best effort I know in this field is the very good
    Apigee - Web Api Design ebook. The e-book is not an attempt to create a bible or a mantra about how to design your api, but rather a collection of conventions observed in large web REST apis, like Twitter, Facebook, Linkedin, Google, etc.

  • How to create a web api ?

    helloo,
    i am using javascript and html in my project and i want to create web api of this project.
    Kindly suggest me what can i do. 

    Hi,
    WebAPI are pretty simple and straightforward like of that webservices and/or wcf....  but I guess you have to ask in different forum:
    http://forums.asp.net/1146.aspx
    And below is the link for the webAPI
    http://msdn.microsoft.com/en-us/library/dn448365(v=vs.118).aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Web API commands in query_view_data

    Hi everybody!
    I´m trying to use Web API commands in the query_view_data Web Service.
    Is somewhere a HOW-TO how this works or some examples?
    Which commands can in general be used?
    thanks and best regards,
    Philipp

    refer:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a249a990-0201-0010-e18e-b2f5ed135497
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/0668a690-0201-0010-c992-cc55062ac207
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/902c3e76-fc1c-2a10-c4ab-c734b06603ba
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/22c29190-0201-0010-2f9e-b2be636b6679

  • How to call a Web Api from from a Visual webpart code behind?

    Hi,
    I am trying to create a visual web part in sharepoint 2013 with data received from another Web API.
    I followed the below steps.
    1. Created a Visual Web part.
    2. In the code behind(.cs) file I wrote the following code.
     async private void GetResult()
                using (var client = new HttpClient())
                    client.BaseAddress = new Uri("http://localhost:8080/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = await client.GetAsync("api/Tfs/OpenEnquiriesCount");
                    var content = response.Content;
    3. When I run the application, I get security exception in the line await
    client.GetAsync()
    What is the way to achieve this? How to call a web api from share point visual web part?
    Thank you in advance.

    Hi,
    Thanks for your sharing.
    Cheers,
    Jason
    Jason Guo
    TechNet Community Support

  • How to upload to Azure Media Services when using HTML5 with Web API

    I keep finding examples demonstrating how to upload video to Azure Media Services through a console application.  I am developing an application using HTML5 with angularjs and web api, but am having trouble finding an example for uploading when you
    are getting the file from a form on a web browser.  The main issue I find is that I see a way to upload from a file path and no way to upload from a stream.  I would like to upload the file to blob storage and then associate the file in blob storage
    with the IAssetFile object, which is then associated with IAsset.  It this possible and if so can you point me in the direction of some tutorials that demonstrate this?  Also, I am allowing site members to upload videos and images.  For this
    images scenario, I saw doc. demonstrating how to start a job that will save the image into a different size, what if I need four different sizes for each image uploaded?

    Hi,
    the following example shows how to upload a stream into a blob and associate the blob with an asset: https://code.msdn.microsoft.com/How-to-upload-a-stream-to-d2750102.
    thanks,
    Julia
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • MS CRM 2015 :DB locking issues while calling a web API inside an asynchronous Plugin.

    Hi,
    We have a SharePoint Integration where a Web API is deployed on SharePoint Server.We are calling this Web API in asynchronous plugin. Although the Plugin works fine. But  its causing DB issues .other custom applications like schedulers are breaking
    and showing time-out issues. 
    I analysed it and found that Web API sometime failed to instantiate the Proxy object ( Exception ::System.Net.WebException: The operation has timed out ).
    This results into the exception in  plugin OR cause of DB locking. 
    Kindly suggest how to resolve this issue.
    Thanks,
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari
    http://microxrm.blogspot.in

    ianp123,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://forums.novell.com/

Maybe you are looking for