HelloWorld REST Web Service

Once the business logic is in place, you can RESTify the EJB methods using the Junos Space SDK plug-in.

CRUD Using the Rest Interface Creation Wizard

  1. Right click on HelloWorld.java and select Create/Edit REST Resources as shown below:

  2. Enter the Interface Target Name and Interface Target File. You can select the default options as well. Click Next.

  3. Select the method to RESTify. For example, getCountryById(int id). A country object can contain several states and hence the "country" object is expected to have reference to object(s) in another collection, for example, /api/space/hello-world/states. After the method is selected to RESTify, Click Add.

  4. Click Next after configuring the URL path and parameters.
    Note: If you want to use Filtering/Sorting, support must be provided at the EJB layer.

  5. Select the fields for the DTO and configure them by clicking Configure.

  6. Configure the fields for the selected DTO. Select a Property Name checkbox and click Configure.

  7. After configuring the property, click Finish. You will be asked to proceed through the rest of the wizard.

  8. Click Next to configure the REST method details.

  9. Click Finish.

  10. Click Finish on the main wizard if you do not wish to RESTify other methods. If you want to RESTify other methods, use the preceding steps.

  11. Verify HelloWorldWebSvc contains the DTO and RESTified classes at the location specified in the wizard. The corresponding XSD is created under HelloWorldWebSvc/WEB-INF.