Run RESTful Client Server in Eclipse - eclipse

I am following the tutorial from this link to learn about RESTful programming.
http://www.vogella.com/tutorials/REST/article.html
I have done the project under '7. CRUD RESTful webservice'.
When I run the Client (heading 7.5) for this project (Run as Application), I should get a form to input the details to be POSTed to the REST web service. But the form is shown in the Console window which shows the raw HTML file rather than the html page as rendered by a browser.
Any suggestions on what I am doing wrongly.
Thank you.

Section 7.5 of that tutorial is just a simple, hard-coded demonstration of interacting with the web service; it is not an app that accepts input and it certainly is not a browser. A (static) HTML page that accepts input and posts to the web service would not be hard to assemble, but it's outside the scope of that tutorial.
If you just need a client to test your REST service, there are lots of choices. For example:
an Eclipse plugin that is a REST client
Postman, a Chrome browser app that does the same thing.

Related

Django Rest Framework redirection after POST success

Is there a way to redirect a form POST to a specific page if the endpoint return a success ?
In my specific case, I'm using django-rest-auth to manage the users authentication, and the login endpoint (/rest-auth/login/) return a JSON with the response. I want to redirect the user to his dashboard if the authentication is successfull.
EDIT : As far as I understand, the REST api is only for backend. If I want to set a redirection after any form post, I have to find a way only with my frontend application. Am I right ?
In this case, is Django a good choice to develop the frontend application ?
I've seen many subjects where AngularJS is mentionned to build the frontend. Is it a good idea to build a client app with JS (I mean, for a one page web api, there is no back and next navigation possibility, I think this is not a friendly way to navigate) ?
If I build my frontend with Django, do I have to write my own view, call the backend rest endpoint in this view, process the result, and send an HTTPRequest (for exemple) from this view ? I don't really understand where is the gain with this method.
Well, answer to your question couldn't be only one solution.
You have two ways:
use full RESTful app, using Django Rest Framework and Single
page application
create your own auth views, where you decide
where to go after logging in
Everything depends on your needs.
If I want to set a redirection after any form post, I have to find a way only with my frontend application. Am I right ?
Yes, you need to do the redirection on the front-end.
In this case, is Django a good choice to develop the frontend application ?
Django is a framework for building web servers, and it has nothing to do with front-end.
I mean, for a one page web api, there is no back and next navigation possibility, I think this is not a friendly way to navigate)
There is. For example, here is the ui-router for angularjs. Here is an example of an actual working page. As you can see, the url changes accordingly, just behaves like traditional server-rendered static html pages.
When the browser sends a request to your server, django calls the corresponding view function to render a view, which is just an html file, and sends it back to the browser. Then the browser renders the page. Beyond this point, django has nothing to do with the html file anymore. It is the browser's job to parse the html, and render it accordingly.
So, to be clear, django is not for front-end. For your web application, you can use angularjs for sure. However, if you don't really want to write a lot of javascript code, I suggest taking a look at Polymer (polymer-project.org, oh my little reputation), which is really easy to use.

Iphone Application with Symfony 1.4

I'm building a simple iPhone app that synchronizes to a webservice served by Symfony 1.4. This app requires the user to be logged in.
My question is, how can the user log in Symfony from the iPhone app? And how can I keep the session opened through the next petitions? Is this secure?
Chapter 15 of the Practical Symfony book talks about webservices, but I can't find any guide about sessions.
Thanks in advance
You can use SOAP web service also. But this is little complex. You can send the file attached to XForm and Post to the service
Detailed implementation of SOAP in PHP
http://www.vankouteren.eu/blog/2009/03/simple-php-soap-example/
You can build a rest service for symfony modules. You can get login through REST service.
Your example service will be like this
www.example.com?username=user&password=pass

Silverlight 4.0 Facebook App - Web vs Native/Desktop

I don't know what to choose. I have a standard Silverlight app hosted in an aspx page.
From the aspx page, in JavaScript, I call some methods like: FB.init() and FB.getLoginStatus().
From the silverlight app code I call the https://api.facebook.com/method/fql.query endpoint using WebClient() class.
Is it Web or Native/Desktop, and what difference does it make regarding OAuth flow, API calls and Security ?
It is web. Native desktop apps run on user computer and web run in the browser.
The difference between Oauth flows on desktop vs. web is described well in details in docs:
https://developers.facebook.com/docs/authentication/
hope this helps

Facebook App via Java Applet

I have a headless Java EE app running on one of my GlassFish servers, and some time ago I wrote up a Swing applet for its front-end. Now I want to make a FB app that uses the same back-end, but I don't want to rewrite the GUI in JS or PHP.
I absolutely detest JavaScript. I've been pouring through the FB dev docs and can't seem to find an answer to this question, but:
Can I just use my applet as the "canvas" for my FB application? If the canvas simply uses an iframe, and the canvas url points to a servlet that runs my applet, is there any reason why that wouldn't work?
I think it works. I read a tutorial to get an applet inside a facebook app using an iframe, so that must work. They had to pass the facebook data in the applet init parameters. there might be another way around to get facebook data into an app if you need that

How to get facebook data from app?

I'm writing a sort of visualization desktop (non-web) application, just for fun.
However, ideally I'd want it to be able to pull information from the user's facebook account. (after getting its credentials, of course)
What's the best way to do this? Should I register a new 'facebook app' even though I'm not really making it web-based? I've never written a facebook app before.
I'm using Java as my prog language, btw.
Thanks!
Yes. Facebook supports desktop applications, but they must go through a special authentication mechanism. Essentially, the user will need to be directed to facebook through a web browser window as part of the authentication process.
Here is the documentation on the authentication process: http://wiki.developers.facebook.com/index.php/Login_Desktop_App
There is a relatively polished Java library for facebook here: http://code.google.com/p/facebook-java-api/
If the Java library above does not meets your needs, you can build an implementation on your own. Essentially, you will need to interact with the Facebook REST server, as described at the top of the page here: http://wiki.developers.facebook.com/index.php/API
Edit: After doing some more research I have a few more resources to provide:
Here is a list of some applications written using Java for facebook:
http://wiki.developers.facebook.com/index.php/Facebook_apps_written_in_Java
And there's even a neat desktop application that is open source here:
http://code.google.com/p/fb-photo-uploader/
Good luck!