views:

440

answers:

1

I am currently reviewing some code for colleagues on a different project and they are using a WCF ReST web service.

My concern is that for each of their methods, only the HTTP protocol POST has been specified. This is true whether the actual method is responsible for getting, updating or creating records.

Should web services at all times still adhere to good HTTP protocol standards for information handling? Shouldn't a method such as that below have an HTTP method of "GET" rather than the specified "POST"?

[ServiceContract]
public interface IBranchService
{
    [OperationContract]
    [WebInvoke(
        Method="POST",
        BodyStyle = WebMessageBodyStyle.WrappedRequest,
        ResponseFormat = WebMessageFormat.Json
        )
    ]
    GridResponse GetBranchesAll(string brandCode, string branchNumber);
...

There are no other constraints around the architecture that dictate that only POST should be used.

+2  A: 

There's no way of answering this without knowing the constraints under which they have designed the API. For example, our API has the capability to work entirely with POST requests because it needs to be called by Flash which has bugs with GET (i.e. cannot send request headers) and cannot send PUT or DELETE. Some Javascript libraries have similar limitations.

Yes, in an ideal world, it would adhere to HTTP semantics. But we don't live in an ideal world. You need to find out whether their decision to use POST is born of ignorance of the HTTP protocol semantics, or from pragmatism based on the limitations of the caller.

Greg Beech