Consuming JSON-RPC web services in .NET
-
21-08-2019 - |
Question
A business partner has suggested building a web services library with JSON-RPC rather that SOAP. (note they are not building in .NET necessarily, but I am)
I am a potential consumer of this data.
I've used JSON for client-based Ajax calls in the past, but this web services library will be used primarily for server-side calls and syncing large amounts of data.
I don't have much experience with JSON-RPC.
Questions:
- Can I easily build a JSON-RPC consumer in .NET?
- Are JSON-RPC web services self documenting and discoverable, like a SOAP WSDL?
- Can I easily add a Web Reference in Visual Studio to a JSON-RPC web service?
Thanks
Solution
Can I easily build a JSON-RPC consumer in .NET?
Yes. JSON-RPC services are simple to consume as long as you have a robust JSON parser or formatter. Jayrock provides a simple client implementation JsonRpcClicnet
that you can use to build a consumer. There is also a small demo sample included.
Are JSON-RPC web services self documenting and discoverable, like a SOAP WSDL?
No, there is nothing standardized but there are ideas being floated around like Service Mapping Description Proposal.
Can I easily add a Web Reference in Visual Studio to a JSON-RPC web service?
This can work if the server-side implementation provides a WSDL-based description of the JSON-RPC service but none are known to provide this to date.
OTHER TIPS
Check out Jayrock.
Jayrock is a modest and an open source (LGPL) implementation of JSON and JSON-RPC for the Microsoft .NET Framework, including ASP.NET. What can you do with Jayrock? In a few words, Jayrock allows clients, typically JavaScript in web pages, to be able to call into server-side methods using JSON as the wire format and JSON-RPC as the procedure invocation protocol. The methods can be called synchronously or asynchronously.
Can I easily build a JSON-RPC consumer in .NET?
Shouldn't be difficult as long as you know what you're doing.
Are JSON-RPC web services self documenting and discoverable, like a SOAP WSDL?
Discoverable yes, documenting in as much as you can get function names and parameter lists. (not entirely sure what you're asking for as far as documentation goes).
Can I easily add a Web Reference in Visual Studio to a JSON-RPC web service?
I don't think so, no. (Though, I have no idea, it's possible. My experience with JSON-RPC is in PHP/JS mostly)
Relevant links:
Maybe you could have a look at json-wsp which is much like json-rpc but with a discription specification. It is implemented as an interface in Ladon for python. http://pypi.python.org/pypi/ladon
I have some sample Json-Rpc 2.0 clients for .net and windows phone 7 in the Json-RPC.NET sources.
Check them out: .Net Client and WP7 Client