We have seen how to create SOAP based web service from java class. Here we will create web service from PL/SQL package.
Description of operations while creating web service
In this example, web service will be created based on calculator functionality. Web service will perform four operations based on four procedures in the pl/sql package. Refer this link for the package.
- Create a PL/SQL package in database and create database connection with the database details in the Application resources, just below the Application tab of jdeveloper 12C.
- Right click on application name and select New -> From Gallery. Create a custom project under the same application XXTestWSAPP
- Enter project name XXCalcWSPrj and select a directory to store this project
- Click on Finish. Now we have to create TopLink DB Web Service Provider to create a web service from pl/sql package. Right click on the project and select New -> From Gallery
- Select TopLink DB web Service Provider under Business Tier category
- TopLink DB web Service Provider creation wizard will open
- Click on Next and select Generation PL/SQL Web Service Provider
- Select database connection and packageA�along with Soap Version
- Then select all the procedures in the selected package which need to be exposed as operation in the service.
- Click on Finish. Web service will be created from pl/sql package. Actually a java file will be created as calculator webservice.
- Test the web service. Right click on DBWSProvider.java file and select Test Web Service
- Select subtract operation and enter two numbers in the request header. Click on Send Request. Response will look like below screenshot
- Copy the URL of this service and open it in browser. This web service can be tested in the browser also
- Select add operation and enter two numbers and click on Invoke
- Test result will be like below screenshot