Monday, July 13, 2020

Inserting data into database in SOA 12c

This post shows you how to insert data into Oracle database using DB Adapter in SOA 12c. If you're new to SOA, please check out my previous post Helloworld in SOA which shows how to create a basic SOA web service.

1. Create a SOA project and give an appropriate name.


Click Next.


Click Finish.


2. Drag and drop a Database Adapter into the External Services swim lane. Give an appropriate name and click Next.


Select the connection. If you don't have a connection, create a new database connection and you need to set up the configuration in weblogic server. If you didn't already set up this configuration in weblogic, click here.

Click Next.


Select the Operation Type as 'Perform an Operation on a Table' and check the option 'Insert only'. Click Next.


In the next screen, we need to import table. So click on Import Tables at the bottom left.


Query the table that you want to import. In my case, I already created a table called po_details_tbl in Oracle database. So I'm selecting the same table.


Select the table by clicking on first arrow symbol and click OK.


Click Next.


Select the column that you want to make up primary key and click Next.


Click Next.


Select the columns that you want to insert data into and click Next. You can select all the columns if you wish to insert data into all of them. In my case, I have selected only few as I want to insert data only into these selected columns.


Click Next.


Click Next to go with the default values.


Click on Finish button to complete the process.


As soon you finish the DB Adapter configuration, corresponding files will be created in your project as below.



3. Now we need to add a BPEL process but before that, lets create a schema for the input values. As you can see, I want to insert data into five columns - CustId, productname, price, quantity and date. So I'm going to create a schema that contains these columns.

To create a schema, right click on the Schemas folder of the current project>Click New>From Gallery>XML Schema(XML). Give a name and click OK.


Create the required elements in xsd and save it. I gave Result element in Response to hold the manual message. You can skip it if you don't want it.


4. Now drag and drop a BPEL process. Select the template as 'Synchronous BPEL Process'. Check the checkbox 'Expose as a SOAP Service'.


Click on the highlighted search button to select the input variable from the schema that we created.


Do the same for output variable. If you didn't create an output variable in schema, don't select anything in BPEL output. Click OK.


Wire the BPEL to DB Adapter.



5. Double click on BPEL. Drag and drop an Invoke activity in between Receive and Reply to invoke the DB.


Double click on the Invoke. Click on the search icon to select the Partner link or you can simply wire Invoke to DB Adapter.


Create input variable by clicking on green plus(+) icon.


Click on Apply and then click OK.


Now drag and drop an Assign activity after Receive activity. Double click on it to assign input values. Assign Input variables from BPEL to Invoke Input variables. Click Apply and OK.


Add another Assign activity after Invoke activity. Edit the Assign activity and add an expression to the Output variable on the right side.


Add a manual success message to it.


Your final composite activities should look like this.


Great!! You've done with creating a project to insert data into database. Now deploy into soa server and test it. Cheers!!

No comments:

Post a Comment

Featured Posts

Sample Real Time Assignment in Oracle SOA