RESTfulWebServicesSamples
RESTful Web Services Samples for NetBeans 6.0
This page lists the RESTful Web services samples for NetBeans 6.0. Sample are in Beta 1.
Customer App
This is a RESTful Web Service Sample which demo the Web 2.0 Client stub in action interacting with REST Web Service Resources. It is based on Client Stub generation from RESTful Web Service Resources
Screenshots:
The following 4 snapshots show the CustomerDB Client (100% Javascript) demonstrating the CRUD (Create, Retrieve, Update and Delete) functionality of RESTful Web Services.
1. Retrieve all customers
This page displays all the customers id, name, email information. It also lets user delete individual customer by clicking 'Delete' button next to each customer row. Click on the link on the Id column to show the customer details including the discount code. Click 'Add' to create a new customer.
2. Retrieve customer '1'
After clicking the link on the Id column for customer with Id '1'. Click 'Edit' button to start editing.
3. Edit customer '1'
This page lets user edit the customer '1' details. After modifying the contents, click 'Update' button to update the changes to the server.
4. Create new customer
This page shows the Create new customer functionality. This is obtained by click 'Add' on the 'View Customers' page (the home page)
Note:
- Delete on existing customers would fail, due to database existing constraint on the CustomerDB 'Customer' table, so try deleting a new customer that you created.
- Create new customer selects a new Id starting from <1000 + max(no of customers in the DB)>.
Preparation:
0. Required Installations:
- JDK 1.6.0_01
- Latest NetBeans 6.0 Beta1 bits - http://bits.netbeans.org/download/6.0/nightly/latest/ (If you choose Full install, then GF gets installed also)
- GlassFish V2 - http://bits.netbeans.org/download/6.0/nightly/latest/ or GF website
- Jersey libraries - https://jersey.dev.java.net/ (try the latest build, for Eg:- https://jersey.dev.java.net/files/documents/7056/66186/jersey-0.2.1-ea.zip)
- Copy Jersery libraries (jars from \jersey-0.2.1-ea\lib) to <GF Install location>/domains/domain1/lib
- Start the IDE (NB 6.0 beta1), go to Tools->Plugins->Available Plugins, search for RESTful Web Services plugin. Install this plugin. Close the plugin manager.
Note:
- If http://bits.netbeans.org/download/6.0/nightly/latest is not available, try http://bits.netbeans.org/download/6.0/nightly/<latest timestamp>
(For Eg:- http://bits.netbeans.org/download/6.0/nightly/200708280000/)
- I found an issue (error with using TopLink JPA Provider) with GF glassfish-v2-b58c build, so try glassfish-v2-b58. Glassfish-v2-b58 can be obtained from GF site.
(See GF issue 3557 for details)
1. Create a 'CustomerDB' RESTful Web Service Application:
- Click on 'New Project' button to bring up the wizard, select 'RESTful Web Services' under 'Samples' category and 'Customer Database' project type. Click 'Next'.
- Select everything default on this 2nd page. Then click 'Finish' to create the 'CustomerDB' Web Application.
Facts:
- Java DB (Derby) integration is included as part of NetBeans bundle. JDBC driver for Java DB, is included by both NetBeans 6.0 and AppServer.
2. Test 'CustomerDB' RESTful Web Services:
- Right click on the project node 'CustomerDB' and select 'Test RESTful Web Services'. The web application will be built, deployed and the default browser will be brought up with the test client page. Select 'customers' link on the tree view of resources (on the left side of the page). Then click 'Test' button to test CRUD (Create, Retrieve, Update, Delete) functionality on resource '/customers/'.
3. Create a 'CustomerDBClient' RESTful Web Service Client Application:
- Click on 'New Project' button to bring up the wizard, select 'RESTful Web Services' under 'Samples' category and 'Customer Database Client' project type. Click 'Next'.
- Select everything default on this 2nd page. Then click 'Finish' to create the 'CustomerDBClient' Web Application.
- Right click on the 'CustomerDBClient' project and select 'Run'. You should see a page "http://localhost:8080/CustomerDBClient". In this page you should see all customers information in a table.
You could now try all the CRUD functionality of RESTful Web Services on this Client application in a easy way.





