Where to start to create a RESTful web service based on the .NET platform?

I am creating an iOS application that I need to connect to the database through a web service. I only know basic knowledge about using RESTful web services, I have never written them before and wondered if you can give me any tips on where I can learn how to write my own RESTful web service.

In my iOS program, I will send the part number to the web service, after which the web service will need to return information about the color and size of the part. I'm not sure if XML is a better format or something is better?

I think my question is twofold:

  • Is this something I have to do with a RESTful web service?
  • Where can I find tutorials on creating a .NET-based RESTful web service?
+6
source share
6 answers

My advice would be to implement this using ASP.NET MVC3 - as this provides a good controller action paradigm that is great for implementing a REST service. You can use WCF, and I'm sure everything will be fine, but from personal experience I found MVC3 very easy to use to write a REST server for an iOS client.

I would recommend using JSON rather than XML, primarily because it is more concise than XML, but it has other advantages if you decide to later implement the web interface for your database, since Javascript has good JSON support.

There are many JSON libraries for iOS, including SBJSON and YAJL

There is also a well-considered infrastructure for iOS REST implementations called RestKit .

As for tutorials on implementing REST using the MVC workshop, it might look like this:.

+5
source

You can use WCF to create RESTful services, and you can use Nancy:

I would recommend using json as the data format, see here for some excelent links: iPhone / iOS JSON parsing tutorial

in wcf you would like to create such a service: see here for a valid example: http://blogs.msdn.com/b/kaevans/archive/2008/04/03/creating-restful-services-using-wcf.aspx

[ServiceContract] public interface IServeStuff { [OperationContract] [WebGet(UriTemplate = "/stuff/{id}", ResponseFormat = WebMessageFormat.Json)] Stuff GetStuff(string id); } public class StuffService : IServeStuff { public Stuff GetStuff(string id) { return new Stuff(id); } } 

Or with nancy http://www.nancyfx.org/ as follows:

 public MyModule : NancyModule { public MyModule() { Get["/stuff/{id}"] = parameters => { return new Stuff(parameters.id).AsJson(); }; } } 

But before listening to all this @PeterKelly, because he is right

+6
source

Having seen that you have little experience with REST, I would first learn about the concept. It’s important to understand that these (these are not just beautiful URLs) before you start developing your service.

  • I would start by reading Chapter 5 of Roy Fielding's dissertation (where the term REST originated - read the entire article if you want).
  • Then I will move on to the excellent RESTful web services .
  • Finally, I would then read RESTful.NET .

If you gave yourself 2 days, you can read, understand and digest all these resources without problems.

You probably end up using WCF - you can get the REST Starter Kit from here

+3
source

You can use anything.

If this is really your only requirement, it would be quite simple to use the ASP.NET "common handler", output information from the request request parameters and write JSON / XML in the response.

But if you expect that in the future the situation will become even more complicated, you will want to use some kind of structure, such as "Bas B" and "iandotkelly".

+1
source

Use WCF data services . It supports XML and json (json is more efficient).

Use this with the Entity Framework in the least amount of development time.

0
source

WCF data services will help you here.

Check out this guide for newcomers to WCF

0
source

Source: https://habr.com/ru/post/902656/


All Articles