I'm implementing a custom WCF REST behavior, it implements/overrides the base WebHttpBehavior but allows for REST communication using a custom serializer. The code is based on Carlos' work here.
I've got it running but the thing is we REALLY want to use the UriTemplate functionality to allow for true REST-ful URIs. Has anyone seen this done or could provide help on finding the right implementation?
We're sticking with WCF on purpose to provide REST and SOAP endpoints at the same time so moving to Web API is not an option here.
The problem may just be that the example is slightly outdated. Also, the implementation class,
NewtonsoftJsonBehavior, is explicitly overriding and throwing anInvalidOperationExceptionwithin theValidate(ServiceEndpoint endpoint)method.Using Carlos' example, remove the validation:
Add a
UriTemplatetoGetPersonor other method:Within the
Serviceclass, add a simple implementation to validate that the arguments are parsed:In the
Program.Main()method, a call to this new URL will parse and return my query string value without any custom implementation: