Mapping URL suffix to operation parameters
Since WCF REST services use normal HTTP GET/POST for operation invocation, all the operation-wide data, like parameters and return value, are encapsulated in a HTTP message body or request header. And for WCF REST operations based on HTTP GET, the parameters are directly embedded in the URL string. By default, HTTP GET-based REST operations will use a query string for carrying input parameters. However, in real-world REST service scenarios, it is more common that we need to use more user-friendly URLs instead of the auto-generated query-string-based syntax so that the client consumers can call the REST service operations more conveniently.
In this recipe, we will demonstrate how we can use the UriTemplate
feature of a WCF REST service to define a custom URL template for service operation.
How to do it...
We will continue to use the CalcService
service as our example here, since the calculation operations are quite good for demonstrating the UriTemplate...