none
Best Practice to creating a WCF RESTful Service RRS feed

  • Question

  • What would be the best method to create a WCF Service which is RESTful?

    That is, need to create a service - that can be consumed by both .Net clients as well as Java / Android Clients.

    I would need a service which can accept a single value and return a single value;

    Then, a single value and return multiple values;

    Then, a single value and return a set of records (dataset);

    Then, can accept multiple values and return all the 3;

    Please let me know the best method for this.


    Karthick S

    • Moved by Barry Wang Monday, August 17, 2015 9:55 AM WCF related
    Saturday, August 15, 2015 3:36 AM

Answers

  • In order to keep future potential changes in mind, create service method signatures with a single parameter of the type of a class that you mark as DataContract and returns a response similarly of the type of class marked as DataContract. There separate request and response classes would give you flexibility to add DataMembers in future if needed without breaking the contract. You can use same approach for all your use cases. Rest clients would be able to pass these parameters in the body. Put UriTemplate attributes on each operationcontract method. And use binding supporting REST of course!


    techy

    Saturday, August 15, 2015 4:02 AM