Simple JSON-RPC Client for .Net Core 1.0.
With bits and pieces from JSON-RPC.NET
Add package reference to dependencies in project.json:
"dependencies": {
...
"JsonRpc.CoreCLR.Client": "1.0.1"
}
The sample app makes an JSON-RPC request to the Guru JSON-RPC Tester service.
You can run the sample inside the src/HelloGuruJsonRpcSample
folder:
# change into sample app folder
cd src/HelloGuruJsonRpcSample
# restore package dependencies
dotnet restore
# run the sample app
dotnet run
The relevant code is:
public static async Task CallTestService()
{
Uri rpcEndpoint = new Uri("http://gurujsonrpc.appspot.com/guru");
JsonRpcWebClient rpc = new JsonRpcWebClient(rpcEndpoint);
// you can use Json.Net JValue if the service returns a value or
// JObject if it returns an object or you can provide your own
// custom class type to be used when deserializing the rpc result
var response = await rpc.InvokeAsync<JValue>("guru.test", new string[]
{
"World"
});
System.Console.WriteLine("RPC Reply: {0}", response.Result);
}
To build the library from source, please do:
# Clone repository
git clone https://github.com/vmlf01/JsonRpc.CoreCLR.Client.git
cd JsonRpc.CoreCLR.Client
# Restore NuGet packages
dotnet restore
# Build NuGet package
dotnet pack src/JsonRpc.CoreCLR.Client --output build
You can also run the tests by doing:
# Run tests from repository root
dotnet test tests/JsonRpc.CoreCLR.Client.Tests
You will need nuget.exe on your path and set the NuGet API Key before you can push a package to the NuGet repository.
nuget.exe setApiKey 76d7xxxx-xxxx-xxxx-xxxx-eabb8b0cxxxx
nuget.exe push .\build\JsonRpc.CoreCLR.Client.0.0.1.nupkg