Exposing a Database as a Web Service, Page 3
Inserting a New Person Object
Inserting a person object also can be done using a REST call. You need to pass the id, name, address, and the age to add a new person into the table. You can pass them as URL query parameters, as you can see below.
http://localhost:8080/axis2/services/
DBSampleService/insertPerson?id=130
&name=Peter&address=No 5, Colombo, Sri Lanka&age=56
Conclusion
You now have a very good understanding about exposing a database as a Web Service using Axis2. The sample you did was a very simple one, but you can write any complex example using this approach. If you have a good understanding about Databases and Axis2, you can do very cool stuff. Trying out the sample and creating your own sample will help you to understand the concept very clearly.
Downloads
- The ServiceLifeCycle implementation class
- person.java
- NameAge.java
- PersonDBService.java
- services.xml
- dbsample.aar
- All the files accompanying this article
References
- Axis2 deployment architecture: www.developer.com/open/article.php/3557741
- Six ways of deployment: www-128.ibm.com/developerworks/library/ ws-axis2soap/index.html
- Axis2 POJO: http://www.developer.com/java/other/article.php/ 10936_3726461_3
Page 3 of 3
0 Comments (click to add your comment)
