Page 1 of 1
REST based API
Posted: Wed Apr 24, 2013 4:24 am
by ghosttie
I'd like to create a RESTful web API for a JADE app.
I was thinking of using an ASP.NET layer to translate between JADE Web Services and REST/JSON but I thought it might perform better to use a C# Exposure instead.
Does anyone have any experience in this area?
Re: REST based API
Posted: Wed Apr 24, 2013 9:43 am
by Dr Danyo
Hi Ghosttie,
I've done something similar which I found worked very well.
In my case I was playing around with the ODATA services, basically as you say, exposure your database persistent classes via the JADE c# exposure feature then create a .net service layer on top of them (with your own data contract / model POCO). If I was doing it again I'd use the new asp.net mvc 4 web api framework , you should be up and running very quickly.
I couldn't say I spent any time looking into performance as I just wanted to see how easy it would be to do, (I'd expect it to be faster, once the JADE node is initiated), I certainly found it a lot simpler to work with.
Dr Danyo
Re: REST based API
Posted: Thu May 02, 2013 11:01 am
by ghosttie
Thanks.
I've just got the exposure up and running and I've set up a test app to call a method in my exposure but I get a JadeSoftware.Joob.Exceptions.JoobNullReferenceException with pretty much any code the exposed method tries to run.
I thought this was like Web Services in that the exposed methods are just entry points and the code in the exposed methods can access non-exposed methods, properties and classes - is this not the case? If not, then will I need to expose the majority of my schemas in order to use them?
The exception doesn't get logged by JADE so it's hard to tell exactly what it's complaining about.
Re: REST based API
Posted: Fri May 03, 2013 3:46 am
by ghosttie
OK, it looks like my 1090's are caused by app being null, which I've never seen before... I'm going to ask Jade Support about it.
Re: REST based API
Posted: Fri May 03, 2013 7:22 am
by Dr Danyo
Sounds like the best way forward. Dont forget to post reason for the problem.
- Dr Danyo.
Re: REST based API
Posted: Fri May 03, 2013 9:26 am
by ghosttie
While we're waiting on that issue, since you've created a WCF (?) service on top of a JADE C# exposure, could you give me some advice on the lifespan of the database connection? In my test application it seems like a Node and 10 Processes are getting created every time I connect. If it was doing this for every request it would do horrible things to the service's performance so I assume that's not how it's intended to work. Does a JoobContext object correspond with a Node? In which case would it make sense to create and hold one JoobContext object have the requests all use the same one?
Re: REST based API
Posted: Sat Jun 15, 2013 8:19 am
by ghosttie
Sounds like the best way forward. Dont forget to post reason for the problem.
To follow up with this, the reason for the problem was that contrary to what the documentation says the app object doesn't exist when running a C# Exposure.
It is fixed in 7.0.08, 7.1.00 and HotFix 7.0.07.012.
Re: REST based API
Posted: Thu Jun 20, 2013 3:23 am
by ghosttie
While we're waiting on that issue, since you've created a WCF (?) service on top of a JADE C# exposure, could you give me some advice on the lifespan of the database connection? In my test application it seems like a Node and 10 Processes are getting created every time I connect. If it was doing this for every request it would do horrible things to the service's performance so I assume that's not how it's intended to work. Does a JoobContext object correspond with a Node? In which case would it make sense to create and hold one JoobContext object have the requests all use the same one?
I'll answer my own question:
A JoobContext corresponds with a Process, although it's not a permanent association - it's temporarily associated with a Process from the pool for the lifetime of the context.
The first time your C# application gets a context, the Node is created and stays around until the C# application terminates.
This behavior should be what you need most of the time, but if you explicitly want the Node to start up or shut down at a specific point you can use the JoobDatabaseService class. For example you might want your service to make a connection to the database as soon as it starts up rather than on the first connection.