Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Services with Google App Engine

I see that Google App Engine can host web applications that will return html, etc. But what about web services that communicate over http and accept / return xml?

Does anyone know how this is being done in Goggle App Engine with Python or for that matter in Java (JAS-WX is not supported)? Any links o samples or articles is greatly appreciated.

Thanks // :)

like image 390
Spanky Avatar asked Jul 28 '09 18:07

Spanky


1 Answers

Google App Engine allows you to write web services that return any type of HTTP response content. This includes xml, json, text, etc.

For instance, take a look at the guestbook sample project offered by Google which shows the HTTP response coming back as text/plain:

    public class GuestbookServlet extends HttpServlet {
        public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
            UserService userService = UserServiceFactory.getUserService();
            User user = userService.getCurrentUser();

            if (user != null) {
                resp.setContentType("text/plain");
                resp.getWriter().println("Hello, " + user.getNickname());
            } else {
                resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
            }
        }
   }

Additionally, the app engine google group is a great place to learn more, ask questions, and see sample code.

like image 88
shek Avatar answered Sep 22 '22 20:09

shek