Can I use TCP in a RESTful service?

前端 未结 6 1023
攒了一身酷
攒了一身酷 2021-01-01 17:29

REST is using current features of the Web and applying some principles on it to make it more efficient. It uses standard HTTP verbs for communication and take help of its st

6条回答
  •  感动是毒
    2021-01-01 18:00

    Slightly different angle:

    1 . Don't use WCF to create REST based services. Use Asp.Net WebAPI.

    2 . Just for fun: if you want to use WCF TCP bindings with 'REST' principles in mind, maybe you can create a stateless API based on 'resources' instead of a typical RPC like one.

    [ServiceContract]
    interface RestApi
    {
        Result Get(string id);
        Result Post(string id, Resource resource);
        Result Put(string id, Resource resource);
        void Delete(string id);
    }
    

    That way you won't have to define different contract for every service and just adjust your resources for different interactions.

    NOTE: I am not suggesting anyone to do this: it's reinventing the wheel. Use WebAPI if you want REST.

提交回复
热议问题