REST based API

For questions and postings not covered by the other forums
User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

REST based API

Postby ghosttie » Wed Apr 24, 2013 4:24 am

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?
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Re: REST based API

Postby Dr Danyo » Wed Apr 24, 2013 9:43 am

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

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: REST based API

Postby ghosttie » Thu May 02, 2013 11:01 am

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.
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: REST based API

Postby ghosttie » Fri May 03, 2013 3:46 am

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.
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Re: REST based API

Postby Dr Danyo » Fri May 03, 2013 7:22 am

Sounds like the best way forward. Dont forget to post reason for the problem.

- Dr Danyo.

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: REST based API

Postby ghosttie » Fri May 03, 2013 9:26 am

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 have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: REST based API

Postby ghosttie » Sat Jun 15, 2013 8:19 am

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.
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: REST based API

Postby ghosttie » Thu Jun 20, 2013 3:23 am

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.
I have a catapult. Give me all the money or I will fling an enormous rock at your head.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 18 guests