Generating RESTful Web Service JavaScript Clients

See Also 

For each RESTful resource class, you can generate a JavaScript client that makes it easy for client applications to access a RESTful service. You can use wizards in the IDE to generate JavaScript clients in web applications and HTML5 applications.

JavaScript Clients in Web Applications

To generate a JavaScript client in a Java web application you can use a wizard to generate a client stub for a local project that contains a RESTful service. The wizard can also generate a stub that is based on the URL of the WADL file of a RESTful service.

  1. Confirm that you have a local project with web service resources or a WADL file.
  2. Right-click the project node and choose New > Other > Web Services > RESTful JavaScript Client.
  3. Specify the project containing the resources or the WADL file. Click Finish.

If you expand the Web Pages node in the Projects window you will notice that you have a 'rest' node that contains the generated JavaScript classes and a 'TestStubs.html' file. You can right-click the html file and choose View to view the generated test page that lists URIs to the client stubs. You can click the URIs to test that the client stub generation was successful.

See the following documentation for more about the Java.net WADL project.

JavaScript Clients in HTML5 Applications

To generate a JavaScript client in an HTML5 application you can use a wizard to generate a client for a local project that contains a RESTful service. In the wizard you also have the option of specifying a table as the user interface.

Perform the following steps to generate a JavaScript client for a RESTful web service.

  1. Confirm that you have a local project with web service resources.
  2. Right-click the project node and choose New > Other > HTML/JavaScript > RESTful JavaScript Client.
  3. Click Browse to specify the location of the REST resource.
  4. Select a UI option and click Next.
  5. Specify a name and location for the generated HTML file. Click Finish.

When you click Finish the IDE generates the JavaScript file in the location that you specified in the wizard. If you selected Tablesorter as the UI for the client, the IDE generates the HTML file with the name and in the location that you specified.

See Also
About Web Services
Generating a RESTful Web Service
Using the Web Service Manager
Testing a RESTful Web Service

Legal Notices