background preloader

Rest

Facebook Twitter

Wadl_stylesheets/wadl_documentation-2009-02.xsl at master · lleseigneur/wadl_stylesheets. Blog.grimwire.com. Guests, patchXHR, and other updates Grimwire/Local.js 0.5 @pfrazee on Nov 19, 2013 link Local.js and Grimwire have been tagged "v0.5 beta" on GitHub today. They are (respectively) an Ajax messaging library and a node.js signalling relay. Together, they broadcast Web services from the page over WebRTC. This version's updates include API refinements and additions, bugfixes, and some optimizations (including much faster async calls in promises and ajax dispatching). Guest Users The biggest addition with 0.5 is an experimental form of guest accounts, which enables users to get streams on the relay without registering first.

Other users can then specify that account as the host during login. They'll be assigned ids based on the host user, eg "bob-guest123". Currently there's no way to restrict guest access to specific users (for instance, by issuing "guest tokens" or setting passwords) so only allocate guest slots when you plan to use them. patchXHR() Other Updates @pfrazee on Nov 19, 2013 link.

NodeCellar: Sample Application with Backbone.js, Twitter Bootstrap, Node.js, Express, and MongoDB. In my previous post, I shared my recent experience building a RESTful API with Node.js, MongoDB, and Express. In this post, I’m sharing the client application that uses that RESTful API. The Node Cellar application allows you to manage (retrieve, create, update, delete) the wines in a wine cellar database. The client application is built with Backbone.js and Twitter Bootstrap. Run the Application You can run the application here.

For obvious reasons, the create, update, delete features have been disabled in this hosted version. NOTE: Node.js is running on port 3000 on my EC2 Instance. Server-Side The details of the Node.js, MongoDB, and Express implementation are documented in my previous post. Client-Side In this application, Node.js is used to provide the RESTful services that the client application needs to manipulate the data. This is a Node.js and MongoDB powered version of an application I initially posted here with PHP and Java backends. Source Code. Creating a REST API using Node.js, Express, and MongoDB. AngularJS, Jersey, JSP and Java EE 6 » Imifos' Lucubratory. The “topro” project (short for “topic proposer”, sorry I wasn’t very inspired on this) is a test that I made to play around with AngularJS.

In the opposite to a lot of AngularJS examples on the net, the project implements the entire chain: AngualarJS on the browser side, REST to communicate with the application server, JAX-RS/Jersey as server-side REST implementation, JSP as templating system of the server-side front-end, Java EE 6 for server-side back-end. The project demonstrates many different things, some of them enumerated hereunder. The choice of using JSP technology for templating may seem strange at first sight. First of all raises the question if we still need server-side templating while having client-side templating with AngularJS. Concerning JSP, one has to admit that, despite of its age, it’s a great and proven technology. For simplification, the project doesn’t use a database. Some things discussed in this project: See web.xml See package eu.lucubratory.topro1.domain.topic.

Using CORS. Introduction APIs are the threads that let you stitch together a rich web experience. But this experience has a hard time translating to the browser, where the options for cross-domain requests are limited to techniques like JSON-P (which has limited use due to security concerns) or setting up a custom proxy (which can be a pain to set up and maintain). Cross-Origin Resource Sharing (CORS) is a W3C spec that allows cross-domain communication from the browser. By building on top of the XMLHttpRequest object, CORS allows developers to work with the same idioms as same-domain requests. The use-case for CORS is simple. As you can see from this example, CORS support requires coordination between both the server and client.

Making a CORS Request This section shows how to make a cross-domain request in JavaScript. Creating the XMLHttpRequest object CORS is supported in the following browsers: Chrome, Firefox, Opera and Safari all use the XMLHttpRequest2 object. Event handlers withCredentials Resources. Integrating Bean Validation with JAX-RS in Java EE 6 » samaxes.

This article was first published on Java Advent Calendar. Introduction to Bean Validation JavaBeans Validation (Bean Validation) is a new validation model available as part of Java EE 6 platform. The Bean Validation model is supported by constraints in the form of annotations placed on a field, method, or class of a JavaBeans component, such as a managed bean. Several built-in constraints are available in the javax.validation.constraints package. The Java EE 6 Tutorial lists all the built-in constraints. Constraints in Bean Validation are expressed via Java annotations: Bean Validation and RESTful web services JAX-RS 1.0 provides great support for extracting request values and binding them into Java fields, properties and parameters using annotations such as @HeaderParam, @QueryParam, etc.

The next release, JAX-RS 2.0, includes a proposal to enable validation annotations to be combined with JAX-RS annotations. However, at the moment, the only solution is to use a proprietary implementation. Janl/mustache.js. RESTful services with jQuery and Java using JAX-RS and Jersey. NOTE: This is the Java version of this article and its companion app. A PHP version is available here. This is a more in depth version of my previous post on the same topic. The previous article only covered the HTTP GET method for building RESTful services. This article (and its new companion app) provides an example of building a complete RESTful API using the different HTTP methods: GET to retrieve and search dataPOST to add dataPUT to update dataDELETE to delete data The application used as an example for this article is a Wine Cellar app.

You can run the application here. Implementing the API using JAX-RS JAX-RS makes it easy to implement this API in Java. Quick look at the JAX-RS annotations used in this class: @GET, @POST, @PUT, @DELETE: HTTP method the class method responds to. The jQuery client below sends data to the server using JSON (addWine() and updateWine() methods). The approach you use to actually retrieve the data is totally up to you.

Testing the API using cURL.

Apps

RESTful Web Services with NetBeans, Jersey and Tomcat | VicHargrave.com. Although Eclipse is commonly used for Java web service programming, it can be challenging to configure and use for testing. Luckily Eclipse is not the only IDE game in town. NetBeans provides a rich environment for developing Java web services with Jersey – the reference implementation of JAX-RS RESTful web services. This article will explain how to create a simple RESTful service and test it with the Apache Tomcat Server from the NetBeans IDE. RESTful Web Services What is REST? Representational State Transfer or REST refers to a design model for distributed systems that was originally described by Roy Fielding, one of the authors of the HTTP protocol versions 1.0 and 1.1. REST involves the transfer of resources between clients and servers. There are no hard and fast rules about what resources are exchanged between clients and servers. HTTP Service Requests RESTful web services are implemented using one or more of the following four HTTP request types depending on the design of the system.

Jersey