forked from jboss-developer/jboss-eap-quickstarts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging 1.0.0.M3b from aerogear/as-quickstarts
- Loading branch information
Bruno Oliveira
committed
Apr 25, 2012
1 parent
8957cd7
commit 5534381
Showing
29 changed files
with
988 additions
and
11,054 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry excluding="js/libs/*" kind="src" path="src/main/webapp"/> | ||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject"> | ||
<attributes> | ||
<attribute name="hide" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/> | ||
<classpathentry kind="output" path=""/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
kitchensink-html5-mobile: JAX-RS Services Documentation | ||
======================================================= | ||
Author: Jay Balunas | ||
Author: Jay Balunas, Marius Bogoevici | ||
|
||
This example supports various RESTFul end points which also includes JSONP support for cross domain requests. | ||
|
||
|
@@ -12,30 +12,6 @@ MemberService End Points | |
### List all members | ||
#### /rest/members | ||
|
||
* Request type: GET | ||
* Return type: XML | ||
* Response example: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="UTF-8"standalone="yes"?> | ||
<collection> | ||
<member> | ||
<email>[email protected]</email> | ||
<id>1</id> | ||
<name>Jane Smith</name> | ||
<phoneNumber>2125551212</phoneNumber> | ||
</member> | ||
<member> | ||
<email>[email protected]</email> | ||
<id>0</id> | ||
<name>John Smith</name> | ||
<phoneNumber>2125551212</phoneNumber> | ||
</member> | ||
</collection> | ||
``` | ||
|
||
#### /rest/members/json | ||
|
||
* Request type: GET | ||
* Return type: JSON | ||
* Response example: | ||
|
@@ -44,14 +20,18 @@ MemberService End Points | |
[{"id":1,"name":"Jane Smith","email":"[email protected]","phoneNumber":"2125551212"},{"id":0,"name":"John Smith","email":"[email protected]","phoneNumber":"2125551212"}] | ||
``` | ||
|
||
### Create a new members | ||
### Create a new member | ||
|
||
#### /rest/members | ||
|
||
* Request type: POST | ||
* Request type: application/x-www-form-urlencoded | ||
* Request parameters: name, email, phoneNumber | ||
* Request type: JSON | ||
* Return type: JSON | ||
* Request example: | ||
|
||
```JavaScript | ||
[{"name":"Jane Smith","email":"[email protected]","phoneNumber":"4160000000"}] | ||
|
||
* Response example: | ||
* Success: 200 OK | ||
* Validation error: Collection of `<field name>:<error msg>` for each error | ||
|
@@ -60,64 +40,11 @@ MemberService End Points | |
{"phoneNumber":"10-12 Numbers","email":"Invalid format"} | ||
``` | ||
|
||
#### /rest/members/new?name=&email=&phoneNumber= | ||
* Request type: GET | ||
* Query parameters: name, email, phoneNumber | ||
* Return type: JSON | ||
* Response example: See POST example above | ||
* Note: JSONP requests do not support error responses | ||
|
||
### Get one member by ID | ||
|
||
#### /rest/members/\<id> | ||
* Request type: GET | ||
* Return type: XML | ||
* Response example: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="UTF-8"standalone="yes"?> | ||
<member> | ||
<email>[email protected]</email> | ||
<id>0</id> | ||
<name>John Smith</name> | ||
<phoneNumber>2125551212</phoneNumber> | ||
</member> | ||
``` | ||
|
||
#### /rest/members/\<id>/json | ||
* Request type: GET | ||
* Return type: JSON | ||
* Response example: | ||
|
||
```javascript | ||
{"id":0,"name":"John Smith","email":"[email protected]","phoneNumber":"2125551212"} | ||
``` | ||
|
||
JSONP Support | ||
------------- | ||
|
||
[JSONP](http://en.wikipedia.org/wiki/JSONP) is a technique for allowing cross domain requests from services. It pads (what the "P" stands for) the service response with a JavaScript callback function that can then access the data on the client. | ||
|
||
In order for a request to be padded the following things must be true: | ||
|
||
* The request is one of the GET JSON request from above | ||
* POST requests are not support for JSONP requests | ||
* A query parameter named *jsonpcallback* is defined | ||
* The value of this parameter is the method that will be defined in the padding | ||
|
||
For example: | ||
|
||
http://\<domain:port>/jboss-as-kitchensink-html5-mobile/rest/members/json?jsonpcallback=mycallback | ||
|
||
See jQuery's documentation for client access examples: | ||
|
||
* http://api.jquery.com/jQuery.getJSON/ | ||
* http://api.jquery.com/jQuery.ajax/ | ||
|
||
__Validation Error Handling__ | ||
|
||
When using JSONP requests error responses are not supported. This is a known issue with JSONP, and has to do with how JSONP requests are sent to the server using \<script> tags. In the case of a validation issue, or error the success callback will not be thrown, and most client libraries (specifically jquery) will not be able to call the error callback either. There are some workarounds and options, but typically they are limited. See your specific client library for more information. | ||
|
||
__Security Considerations__ | ||
|
||
Before using JSONP in your system be aware of some potential security issues that are possible. There are two primary concerns, cross-site request forgery, and script tag manipulation. This example show one way to add a layer of security, by only processing JSONP requests with "safe" characters, it makes it more difficult for a site to injects harmful scripts into the return. You should always consider this and other aspects of security when exposing services in this way. See the [JSON wiki](http://en.wikipedia.org/wiki/JSONP) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.