-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you get returned data from the request? #2
Comments
Hi, client.Invoke returns the response from the server deserialised as the generic type specified after Invoke, so when it says client.Invoke<int> The <int> part says we expect an integer returned from the server, and the result of the Invoke call will be an integer. You ask for a different type of result by changing the generic argument; //Request a string
var greeting = await client.Invoke<string>
(
"GetGreeting",
new Dictionary<string, object>()
{
{ "Language", "English" },
{ "Name", "Yort" }
}
).ConfigureAwait(false);
//Request a 'customer' where 'Customer' is class you've defined.
var foundCustomer = await client.Invoke<Customer>
(
"GetCustomerById",
new Dictionary<string, object>()
{
{ "Id", 1234 },
}
).ConfigureAwait(false); If the server returns an error, or a network error occurs etc. then an exception is thrown. So you either get the type you asked for as the result, or an exception. There is no access to 'underlying data' as the point of the library is to abstract away the transport/protocol details. You either get a valid response from the server or an exception. I hope that helps. |
Yortw… I get it! Took me a min.
Looking deeper into your code it looks like I need to tweak some of the underlying models in order for it to work in my implementation. Specifically the Request and Response. I’m hitting an external firewall vendors API and they loosely use the JSON-RPC model for there purposes. Defining RPC version 2.0 breaks the request and the response returns a session key which must be included in all future requests. The actual method is embedded as a URL parameter in the params object while the method name refers to “get, exec, add”, etc.
The fastest way I can think to do this would be to essentially recreate your library, leaving most of the code intact as is. Is there a particular place you would like me to cite credit?
|
Wow, that's annoying they didn't follow the spec. Forks are welcome! If it's going to be on Github then just in the Readme.md is fine for attribution, thanks 😊 if not then a comment in the main client class or assemblyinfo would be OK. The more important thing I'd ask is that you make sure the namespaces, assemblies and embedded id's (like any COM guids in assemblyinfo.cs) are changed so that if anybody needs to use both libs together they don't conflict. Good luck with your project! |
Thinking about this, but it may be possibly for you just to replace the jsob project. The core spooky Lib might still work, if you just replace the bit that does the request/response formatting. I recently did this to support XML-RPC. Maybe this is what you meant though? |
Yeah, pretty much. I see that your JSONRPC just extends the underlying RPCclient, so I’d pretty much be doing the same thing and just extending the Response and Request Models to include an additional fieldset. Thanks!
Respectfully,
Daniel S. Davis | Independent Consultant
DNA Technology Solutions
P: (207) 299-3274
Email: daniel@dnatechnologysolutions.com <mailto:daniel@dnatechnologysolutions.com>
From: Troy Willmot [mailto:notifications@github.com]
Sent: Friday, January 5, 2018 3:43 PM
To: Yortw/Spooky <Spooky@noreply.github.com>
Cc: DNATechAdmin <daniel@dnatechnologysolutions.com>; Author <author@noreply.github.com>
Subject: Re: [Yortw/Spooky] How do you get returned data from the request? (#2)
Thinking about this, but it may be possibly for you just to replace the jsob project. The core spooky Lib might still work, if you just replace the bit that does the request/response formatting. I recently did this to support XML-RPC. Maybe this is what you meant though?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#2 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AbdEY6Jrk-WP9wk21uk0nrAZ24VpJLIzks5tHollgaJpZM4RTjst> . <https://github.com/notifications/beacon/AbdEY2WOgFIoOIu7DOcRCWvINbRoFofqks5tHollgaJpZM4RTjst.gif>
|
This is a great example on implementing your code. Does client.Invoke only ever return an int?
What do we do to access the underlying data?
The text was updated successfully, but these errors were encountered: