I opened the Netbeans IDE that was installed on my laptop.
I created a New Project named "OnlineDatabaseService" by clicking on File from the menu then selected New Project from the windows dialogue box that came up i selected Java Web and then Web Application. i named my project OnlineDatabaseService, set it as the Main project then next to specify the server that i will be using to deploy the project and the path. so i selected the GlassFish v3 server from the window that was displayed. then finish and my project was automatically created in the netbeans IDE.
I proceeded to create my web service. I right-clicked on the OnlineDatabaseService project that was created, selected New then Web Service and named my Web Service OnlineDBWebService specified the package as server then selected the Create Web srvice from Scratch then finish. My Web Service was created with the Source and Design window being displayed on the coding area of the netbeans.
The next step was to create the database. I again right-clicked on the OnlineDatabaseService selected New then Entity Classes from Database. I selected the data Source as jdbc/sample then from the Available table i highlighted the Customer table and clicked on Add which took me to the next window where i specified the names and the location of the entity classes of my new table. This time around i change my source package for the database to database. Again i ticked the check box for Generate Named Query Annotations for Persistent Fields created the Persitence Unit which i named as OnlineDBWebServicePU then finish to create my Database for the project.
Next, I declared the operation parameters and initate the method. i clicked on the design tab on the coding area, on the window that was displyed i clicked on Add operation button. on the property window that was displayed i typed in the operation name as CustomerDBNumber then clicked on the Add button to add the parameters name which i declared as index and Type as int then ok.
Next, was to initiate the method calls. on the public class OnlineDBWebservice, i initated the PersistenceUnit and the EntityManagerFactory code (see practical coursework submitted to CITE, UEL). again i proceeded to the operation CustomerDBNumber with parameter index and initiated the method call for querrying the created database Customer (see practical coursework submitted to CITE, UEL).
My Web Service was good to go. so i deployed it to the server by right-clicking on the said Web Service project OnlineDatabaseService then select deploy to deploy the web Service on the Glassfish v3 server. The process displayed Build Succesful. to run the web service on the server, I right-clicked on the OnlineDBWebService then selected Test Web Service which took me to the browser where i viewed my Test page.
For the Screenshot of my Web Service (see practical coursework submitted to CITE, UEL)
No comments:
Post a Comment