locked
Do I need to build a web API or Web service for this? RRS feed

  • Question

  • User747696199 posted

    Hi,

    I'm building a MVC3 web app, using ASP.NET4 and C#; at this point my app needs to interact with an existing app that was developed in 2008, using WinForms, C# and ASP.NET2.

    For conveniece I will refer to the existing old app as "A", and my new app as "B".

    A - hosted on a server running Windows 2003 and SQL 2005; using ASP.NET2, Windows Forms;

    B - hosted on a server running Windows 2008 and SQL 2008; using ASP.NET4 and MVC3.

    Now my questions in details:

    1) From A (using MVC3) - if I need to access data (read and write) from some tables in app B (using SQL 2005), what is the best way to do that?

    Note: Someone suggested to build a "web service", and code project; I read thru this article but am not sure if the info is old, since this articke below was written in 2003; today how does VS2010 handle web service? Is ".asmx" file or "wsdl.exe" still in use in a MVC app?

    http://www.codeproject.com/Articles/4379/Introduction-to-NET-Web-Services

    2) From A (using MVC3) - if I need to call certain Stored Procedures and Functions that are in the DB of app B, performing actions on the tables in app B, then pass the "result" data to app A - how do I do that?

    3) Same needs from B (using Win Forms) to A - I need to access the data stored in the tables of app A, for both read and write; when I figure out how to do the above 1) and 2), will the same method work for the flow of "from B, access A's database"?

    I read thru the article from the above link, and other info on "Web Service" - but I really need to see some code working on this subject.

    Can someone provide some sample code or point me to a url that has that?

    Thank you very much - I'll wait and check any reply often.

    Claudia

    Sunday, June 17, 2012 11:30 PM

All replies

  • User633086528 posted

    Hi claudia,

    I will suggest you to go for Web API.

    Reason being it is faster and resource oriented , best suited for read write operations.

    Web Service

    • It is based on SOAP and return data in XML form.
    • It supports only HTTP protocol.
    • It is not open source but can be consumed by any client that understands xml.
    • It can be hosted only on IIS.

    Web API

    • This is the new framework for building HTTP services with easy and simple way.
    • Web API is open source an ideal platform for building ReSTful services over the .NET Framework.
    • Unlike WCF Rest service, it uses the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats).
    • It also supports the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection, unit testing that makes it more simple and robust.
    • It is light weight architecture and good for devices which have limited bandwidth like smart phones and can be hosted with in the application or on IIS..
    • Responses are formatted by Web API’s MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.

    Monday, June 29, 2015 6:35 AM