I've
posted a sample console app as a gist and also attaching it to this post.
Here's a brief explanation of how it's done…
A custom
JsonRpcDispatcher implementation is registered. In an
ASP.NET app, you could do this in
Global.asax The custom implementation is to make the request available downstream by associating it with the service instance.
A custom attribute called
JsonRpcOptionalParametersSupport, and which is decorated on
Getwork, acts as a method description modifier (implementing
IMethodModifier) and hijacks the invocation handler. During invocation, it checks if enough arguments are supplied before the target method is truly invoked. In case too few arguments are supplied, default values from optional parameters are added. If the JSON-RPC request used named arguments by supplying a JSON object for
params then the implementation goes on to fill default values from target method's optional parameters where the parameter is
absent in the source request.
Hopefully the rest of the sample is clear and self-explanatory.