Tags
11G, BPEL, Console, Database Adapter, DBAdapter, Deploy, Deployment, Developer, INSERT, JDeveloper, Oracle, SOA, Soa-Suite
In a previous post I showed how to perform a Select in the database using the DbAdapter component of BPEL, now hold a very similar process but performing an Insert In this example we will receive three parameters of our service for inserting the necessary information to register a new department in our table departments.
For our tests, we will create a project called InsertDBAdapter
Click File >> New
Will open a screen like below:
Then select Generic Project
Project Name InsertDBAdapter place and select the SOA Technologies Project name and click the small arrow> to the name go right and be as below:
Note: See the Directory that it will automatically fill in the name will be created where the project name you entered in the Project Name In my case:/home/uans/jdeveloper/mywork/UansBlogApplication/InsertDBAdapter
Click Next and then:
Below click Finish leaving the Composite Template in Empty Composite
Now we create an empty project will create a BPEL
Now right click Componets > Insert > BPEL Process
Click BPEL 2.0 Specification
In place name InsertDBAdapterBPELProcess
In select Template Asynchronous BPEL Process e clique em OK
In Service Name just let the name insertdbadapterbpel
Let selected option Expose as a service SOAP, as this will be responsible for creating a WSDL default which will change for our tests.
We will now change our WSDL created for inserting our input parameters that will be used in our DBAdapter.
To do this, click on our project created and xsd folder double-click the xsd that was automatically created InsertDBAdapterBPELProcess.xsd
Now let’s change our input parameters.
Inside Tag <element name=”Process”> who are our input parameters, change and add the values below:
<element name=” numeroDepartamento” type=”integer”/> <element name=” nomeDepartamento” type=”string”/> <element name=” localDepartamento” type=”string”/>
Inside Tag <element name=”processResponse”> in result, leave as is.
Here’s how it went:
Now let’s create our Database Adapter (DBAdapter)
In External References click the right button and choose Database Adapter
On the next screen click Next
Service Name in place InsertEmployeeDBAdapter and click Next
On the next screen make sure that your Connection is correct in the case, pointing to the correct database, and JNDI Name is also with the correct name.
In my case is pointing to my OracleXE database
If you have not created yet, do the following:
Click the + icon next to the name of your Connection
On the next screen fill as the image below:
Note: In my case, I am pointing to the base of my Oracle XE, in your case you can put the data regarding the basis on which you will connect and then click Test Connection to make sure you have correctly entered the information from your bank Data and click OK
You should then look like this:
If you do not know the name that should be in JNDI Name, check my Post: Adding a New Database to DbAdapter the Console (Web) SOA Suite 11g for this post I describe how to set up a new base to DbAdapter (WEB), but if you still have doubt where is this name, enter the Web Console as follows:
In your browser go to http://localhost:10000/console
Note: The port 10000 is the number that I chose to create my Domain.
Login:
Click Deployments
Click DbAdapter
Click Configuration
Click Outbound Connection Pools and then click the beside javax.resource.cci.ConnectionFactory
Below are my connections connections and there we have the I’m using in DBAdapter in the case: eis/DB/OracleXe and this will be the name JNDI Name that we will use in our DBAdapter
Returning to our DBADapter, then we have the screen below, then click Next:
In the screenshot below, select Insert Only and click Next:
Now click Import Tables for caring about our table which we will do Insert
On the next screen in Name Filter place %DEPARTMENT%
Note: I am using % so you can see it is possible to use the percent sign to find the table if you do not know the exact name, and then click Query and below in Iran Available be shown to your table, but if it appears not see the creation of your settings if your User has the appropriate permissions to access this table and / or the Owner is correct.
Now click on your table and click the arrow > to your table go to the right side as shown below and click OK.
Below you made the import correctly, since now the DEPARTMENT table appears on our screen, now click Next:
The next screen click Next
Click Next again
Click Next again
Click Finish
Then we have the following:
Now place the mouse cursor over the BPEL, if the blue box ai means until an arrow orange, then hold the left mouse button and drag to the other small arrow of your DBAdapter:
Now double-click on your BPEL, and right on the screen in BPEL Constructs click the Invoke component and drag to the center of your BPEL:
Drag the small arrow that appears next to your Invoke for your DBAdapter that will appear in Partner Links
After that will be shown the following screen:
Then the input tab click the green + sign to create the input variable, if that will give name to your input and see that it will create another canister filled with the name of variable for Invoke1_insert_InputVariable, then click OK
Now place the following in Name: Insert_Invoke and click OK
We will then have the following screen after we clicked OK.
Now drag an Assign to above your Invoke as follows:
In Assing1 rename it to Variaveis_Entrada for it just double click on the name Assign1
Now double-click on the Variaveis_Entrada box, click the + sign inputVariable to get client:numeroDepartamento, (left) and drag to the ns2:deptno that will be in Invoke1_Insert_InputVariable the right side as shown below and click OK.
Also do the same ligament in his left side to the right side with the other items in the case:
- client:nomeDepartamento –> ns2:name
- client:localDepartamento –> ns2:location
Note: This Invoke1_Insert_InputVariable is the same variable we set for the Invoke we created above.
Do deploy your project to test: Right-click on your project (InsertDBAdapter) click Deploy > InsertDBAdapter …
Click Next
Select the Overwrite any existing composites with the same revision ID and uncheck the option Keep running instances on after redeployment and click Next
Select the localhost option and click Next
Click Next again
Now click Finish
In its JDeveloper and below, click the Deployment tab and see if the message — Deployment finished. —– If you see your deployment was executed successfully, if it does not check the steps above again to see if you forgot to do something.
Let’s do the test to make sure everything worked perfectly.
In your browser go to http://localhost:10000/em
Note: The port 10000 is the number that I chose to create my Domain.
Login:
Click on your project: InsertDBAdapter[1.0]
Click Test
Place the following values as below and click Test Web Service
- numeroDepartamento = 50
- nomeDepartamento = SISTEMAS
- localDepartamento = OSASCO
If no Response appears as below, your project is successfully completed.
To make sure that your data has been successfully inserted refer to your data bank if that’s OK
Doubts? Leave your comment and download this Projet
Hugs and to the Next
/:-D
Namitha said:
Hello Sir,
I have created a DB Adapter for insert/update. I wanted to know whether after the execution of insert/update, will any value be returned from DB Adapter? like a status variable or something similar. My requirement is to send an email (with success msg) if the insert/update is executed successfully otherwise I need to send an email with failure msg.
Thank you.
Uans said:
Hello Namitha,
To be absolutely sure of their implementation in this case perform a new select where you made the update or insert to make sure that the new record is inserted or updated, then put an IF checking if the select returns empty or not.