George Bora
George Bora

Reputation: 1650

Create a REST-ful services with Matlab?

I know it's possible to use REST-full web services from Matlab via the webread method, but what I want to do is expose some matlab functions I've written as REST-full web-services.

Is this possible to do from matlab itself ?

I guess it should be as there is the webread method for consuming REST-full services, but if it's not possible doing this natively from matlabcould I do by writing the services in java then calling the matlab code from java?

Upvotes: 3

Views: 1403

Answers (1)

FullStack
FullStack

Reputation: 6020

It is certainly possible. To share my experience, my team and I built SaturnAPI using Octave (the open-source Matlab clone). It provides hosting for your scripts as well as a RESTful API you can use to access it. Here's a visual of how it works:

Figure 1. Basic flow of HTTP traffic between your web app and SaturnAPI.

Your script is hosted on the SaturnAPI server and accepts SaturnParams as input, which is provided by the incoming HTTP request from your web app. SaturnParams can be a string, number, array or cell array. The cell array allows various data types to be passed into the API.

Once inside the server, the script runs with the SaturnParams and the output is sent as the HTTP response back to the originating server (i.e., your web app). You can see that with this method you can use whatever script you like.

Accomplishing all that was by no means a trivial matter, as you have to set up the web server to accept and respond to HTTP requests. You then have to build an interface for users to upload and test their scripts, which involves managing a database on the server. Then you have to think about scalability and load balancing. If you have further questions, I am happy to share more.

Upvotes: 3

Related Questions