The eXo IDE application provides the original approach to operate with REST Service to validate, deploy/undeploy and launch applications, which are compatible with the JSR-311 specification without restarting the server, or installing additional programs:

Operation User with "developer" role User with "administrator" role
Validate Enabled Enabled
Deploy Disabled Enabled
Undeploy Disabled Enabled
Deploy in Sandbox Enabled Enabled
Undeploy from Sandbox Enabled Enabled
Set/Unset Autoload Disabled Enabled
Run in Sandbox Enabled Enabled
Launch REST Service Disabled Enabled

With eXo IDE, you can validate REST Service before saving, deploying, launching or undeploying the service. The feedback from server is displayed in the Output tab:

All REST Service commands are placed at the right part of the toolbar and in the Run from the top menu.

To clear the Output pane, click at the right top corner of this pane.

Deploy a REST Service

1. Save the file before deploying.

2. Open the saved file in the Content pane.

3. Click on the toolbar;

Or, go to Run --> Deploy from the top menu.

The deployment request is sent to the server. In case of no errors, the message is displayed in the Output tab as below:

[INFO]rennes.groovy deployed successfully

Otherwise, there will be an error message, for example:


[ERROR] rennes.groovy deploy failed. Error (400: Bad Request)
Unexpected error. Error occurs when parse stream, compiler error:
startup failed, rennes.groovy: 4: unable to resolve class javax.ws.rs.Path1
@ line 4, column 1.rennes.groovy: 8: unable to resolve class Path , unable to
find class for annotation
@ line 8, column 1.rennes.groovy: 11: unable to resolve class Path , unable to
find class for annotation
@ line 11, column 3.
3 errors

Undeploy a Rest Service

1. Select the service deployed in the Workspace pane.

2. Double-click the selected service to open it in the Content pane.

3. Click on the toolbar.

In case of no errors, there will be a message informs undeploying successfully in the Output tab.

[INFO] /repository/collaboration/rennes.groovy undeployed successfully.

You can deploy multiple REST Services, and double-deploy the services. However, you cannot undeploy services which were not previously deployed. In this case, you will receive an error message from the server as below:

With eXo IDE, you cannot only write and deploy services, but launch these services and view service response in the Output tab. You can view WADL-description of methods, make requests with your own header, query, path parameters and body content using one of the supported methods. To do that, simply click on the toolbar,

Or, go to Run --> Launch REST Service... from the top menu as follows:

1. Select the deployed REST Service.

2. Click on the toolbar to get the REST Service form which is relied on the WADL-description of REST Service.

3. Select and type the path to the service in the Path field. Path parameters are enclosed in curly braces.

4. Select one of the supported methods from the Method combo-box.

5. Select the appropriate Request Media Type.

6. Check the Response Media Type.

7. Uncheck the redundant query parameters and set values of the rest in the table at the bottom of the dialog window.

8. Go to the Header Parameters middle tab and set appropriate values.

9. Set request with the body content within the Body tab. This tab is disabled for the GET request.

10. Click Send.

You will receive a success message if the path is verified to be correct or an error message in the Output tab.

To learn about launching REST Service, see the REST Service operations illustration above.

The following table shows annotations of reproducing service in the Launch REST Service form:

REST Service Annotation Element of Launch REST Service form
@Path The Path field
@GET, @POST,... The Method field.
@Consumes The Request Media Type field.
@Produces The Response Media Type field.
@PathParam The path parameters figured in curly braces, for example, /service/{param}/{paramList: .+}.
@HeaderParam The Header Parameter tab of the bottom table.
@QueryParam The Query Parameter tab of the bottom table.
@DefaultValue The By default column of the bottom table.

1. Create, save and deploy the REST Service with the next content:

2. Select Run --> Launch REST Service... from the top menu, or click on the toolbar.

3. Select the Path field as "/testMediaTypes", method OPTIONS, then click Send.

The OPTIONS request is sent. You will see the response in the Output tab. For example:



<application xmlns="http://research.sun.com/wadl/2006/10">
   <resources base="http://192.168.0.8:8080/rest">
      <resource path="/testMediaTypes">
         <method name="OPTIONS">
            <response>
               <representation mediaType="application/vnd.sun.wadl+xml"/>
            </response>
         </method>
         <resource path="InnerPath/{pathParam}">
            <param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="pathParam" style="template" type="xs:string"/>
            <method id="post1" name="POST">
               <request>
                  <param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Test-Header1" style="header" type="xs:string"/>
                  <param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Test Query Parameter 1" style="query" type="xs:string"/>
                  <representation mediaType="application/xml"/>
               </request>
               <response>
                  <representation mediaType="text/html"/>
               </response>
            </method>
            <method id="post2" name="POST">
               <request>
                  <param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Test-Header2" style="header" type="xs:string"/>
                  <param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Test Query Parameter 2" style="query" type="xs:string"/>
                  <representation mediaType="application/xml"/>
               </request>
               <response>
                  <representation mediaType="application/json"/>
               </response>
            </method>
         </resource>
      </resource>
   </resources>
</application>

4. Open the Launch REST Service... form again and select the another Path field:

5. Select the Response Media Type = "text/html" item.

6. Enter "/testMediaTypes/InnerPath/value1" in the Path field. In the Query Parameter tab, set "Test Query Parameter 1"="value2". In the Header Parameter tab, set "Test-Header1"="value3". In the Body tab, type "example".

7. Click Send.

The request is created and then sent. You will see the response in the Output tab:


[OUTPUT] - -Status - - - - - - - -
200 OK
- -Headers- - - - - - - -
Server : Apache-Coyote/1.1
Content-Type : text/html
Transfer-Encoding : chunked
Date : Mon, 05 Jul 2010 09:06:55 GMT
- -Text - - - - - - - - -
PathParam 1:value1; Test Query Parameter 1: value2; Test-Header1: value3; Body: example
Copyright © 2009-2012. All rights reserved. eXo Platform SAS