BPEL

Inserting data using the Database Adapter (BPEL DbAdapter) Oracle SOA Suite 11g

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

Imagem Blog UansCarvalho

Will open a screen like below:

Then select Generic Project

Imagem Blog UansCarvalho

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:

Imagem Blo UansCarvalho

Below click Finish leaving the Composite Template in Empty Composite

Imagem Blog UansCarvalho

Now we create an empty project will create a BPEL

Imagem Blog UansCarvalho

Now right click Componets > Insert > BPEL Process

Imagem Blog UansCarvalho

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.

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

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:

Imagem Blog UansCarvalho

Now let’s create our Database Adapter (DBAdapter)

In External References click the right button and choose Database Adapter

Imagem Blog UansCarvalho

On the next screen click Next

Imagem Blog UansCarvalho

Service Name in place InsertEmployeeDBAdapter and click Next

Imagem Blog UansCarvalho

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

IImagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

You should then look like this:

Imagem Blog UansCarvalho

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:

Imagem Blog UansCarvalho

Click Deployments

Imagem Blog UansCarvalho

Click DbAdapter

Imagem Blog UansCarvalho

Click Configuration

Imagem Blog UansCarvalho

Click Outbound Connection Pools and then click the  javax.resource.cci.ConnectionFactory Expand Node beside javax.resource.cci.ConnectionFactory

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Returning to our DBADapter, then we have the screen below, then click Next:

Imagem Blog UansCarvalho

In the screenshot below, select Insert Only and click Next:

Imagem Blog UansCarvalho

Now click Import Tables for caring about our table which we will do Insert

Imagem Blog UansCarvalho

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.

Imagem Blog UansCarvalho

Now click on your table and click the arrow > to your table go to the right side as shown below and click OK.

Imagem Blog UansCarvalho

Below you made the import correctly, since now the DEPARTMENT table appears on our screen, now click Next:

Imagem Blog UansCarvalho

The next screen click Next

Imagem Blog UansCarvalho

Click Next again

Imagem Blog UansCarvalho

Click Next again

Imagem Blog UansCarvalho

Click Finish

Imagem Blog UansCarvalho

Then we have the following:

Imagem Blog UansCarvalho

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:

Imagem Blog UansCarvalho

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:

Imagem Blog UansCarvalho

Drag the small arrow that appears next to your Invoke for your DBAdapter that will appear in Partner Links

Imagem Blog UansCarvalho

After that will be shown the following screen:

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Now place the following in Name: Insert_Invoke and click OK

Imagem Blog UansCarvalho

We will then have the following screen after we clicked OK.

Imagem Blog UansCarvalho

Now drag an Assign to above your Invoke as follows:

Imagem Blog UansCarvalho

In Assing1 rename it to Variaveis_Entrada for it just double click on the name Assign1

Imagem Blog UansCarvalho

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.

Imagem Blog UansCarvalho

Do deploy your project to test: Right-click on your project (InsertDBAdapter) click Deploy > InsertDBAdapter

Imagem Blog UansCarvalho

Click Next

Imagem Blog UansCarvalho

Select the Overwrite any existing composites with the same revision ID and uncheck the option Keep running instances on after redeployment and click Next

Imagem Blog UansCarvalho

Select the localhost option and click Next

Imagem Blog UansCarvalho

Click Next again

Imagem Blog UansCarvalho

Now click Finish

Imagem Blog UansCarvalho

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:

Imagem Blog UansCarvalho

Click on your project: InsertDBAdapter[1.0]

Imagem Blog UansCarvalho

Click Test

Imagem Blog UansCarvalho

Place the following values as below and click Test Web Service

  • numeroDepartamento   =  50
  • nomeDepartamento      =  SISTEMAS
  • localDepartamento       =  OSASCO

Imagem Blog UansCarvalho

If no Response appears as below, your project is successfully completed.

Imagem Blog UansCarvalho

To make sure that your data has been successfully inserted refer to your data bank if that’s OK

Imagem Blog UansCarvalho

Doubts? Leave your comment and download this Projet :-)

 

Hugs and to the Next

 

/:-D

Criei este Blog destinado a desenvolvedores e interessados na Tecnologia Oracle SOA Suite, minha idéia é que no futuro ele sirva de referência para Analistas e Desenvolvedores desde aprendizes a especialistas. Já existem alguns Posts interessantes que abordam um pouco do meu dia a dia, no passar do tempo irei alimentar este Blog com o máximo de informações possíveis, por isso peço por gentileza aos interessados e afins que caso tenham alguma dúvida, sugestão ou crítica que me digam para que eu possa da melhor forma suprir as expectativas e na medida do possível sanar todas as duvidas que vierem a surgir ou até mesmo criar novos Posts abordando algum tópico que venha a ser relevante para todos os interessados. Obrigado Uans Carvalho

2 Comments

  • Namitha

    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

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *