BPEL

Creating a Business Rule in BPEL

A Business Rule is a rule that defines or constrains some aspect of the business. His statement is determined as true or false. Business Rules seek to determine the business structure or to control or influence business behavior.

“http://en.wikipedia.org/wiki/Business_rule”

Here we create a simple Business Rule that will define as our input parameter if it is a person PHYSICAL(FISICA) type or type LEGAL(JURIDICA)

First of all it is interesting that you make sure your COMPOSER is active on your domain, to see this Post: Enabling SOA Composer in Oracle SOA Suite 11g

After that, we will create a project called BusinessRuleBpel

Click File >> New

Imagem Blog UansCarvalho

Will open a screen like below:

Then select Generic Project

Imagem Blog UansCarvalho

Project Name BusinessRuleBpel place and select the SOA Technologies Project name and click the small arrow > to the name go right and be as below:

Click Next and then 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

Click BPEL 2.0 Specification

In place name BusinessRuleBPELProcess

In Template select Synchronous BPEL Process and click OK

Let selected option Expose as a service SOAP, as this will be responsible for creating a WSDL and XSD default which will change for our tests.

Imagem Blog UansCarvalho

Ready, it should look like this:

Imagem Blog UansCarvalho

Open your BusinessRuleBPELProcess.bpel

Imagem Blog UansCarvalho

Among the receiveInput and replyOutput drag a Business Rule component as follows:

Rename the RULE1 to TipoPessoaRule, you just double-click on the name.

Imagem Blog UansCarvalho

Double-click on the TipoPessoaRule box and click the plus sign + beside Dictionary

Imagem Blog UansCarvalho

On the next screen we set the name of our Rule, and the input parameters (input) and output (output).

In Name: TipoPessoaRules place and click the plus sign + then on Add input Variable

Imagem Blog UansCarvalho

Now click the second box Variables in Process and click the plus sign +

Imagem Blog UansCarvalho

In Name: Enter TipoPessoa and click the magnifying glass

Imagem Blog UansCarvalho

Project Schema Files, select the process option and click OK

Imagem Blog UansCarvalho

Then we initialize our Rule with our input

Then, click the Initialize tab and select the option payload within inputVariable as follows:

Note that in XPath will as $inputVariable.payload

Imagem Blog UansCarvalho

Leave Selected TipoPessoa the option and click OK

Imagem Blog UansCarvalho

Now again on the screen below and click the + and now click Add OutputVariable

Imagem Blog UansCarvalho

Click Variables and click the plus sign +

Imagem Blog UansCarvalho

Name Mensagem in place and click the magnifying glass

Imagem Blog UansCarvalho

Project Schema Files select the processResponse option and click OK

Imagem Blog UansCarvalho

Click OK again

Imagem Blog UansCarvalho

In the screen below select the Mensagem name and click OK

Imagem Blog UansCarvalho

Ready, your screen should be as follows, see that now define our input and output, now click OK

Imagem Blog UansCarvalho

After clicking OK was then created our TipoPessoaRules.rules rule as below, then click Create Rule to define our rules by IF / THEN

Imagem Blog UansCarvalho

We will take the appropriate names  🙂

Place names as follows, noting that to rename just click on the name and give a ENTER

  • Ruleset1 – Rename to TipoPessoaRuleset
  • Rule1 – Rename to PessoaFisicaRule

It should look like this:

Imagem Blog UansCarvalho

Now let’s define our terms:

Just below the IF click <insert test> and will appear automatically <operand> == <operand>

Click the first <operand> and select the option TipoPessoa >> input

Imagem Blog UansCarvalho

Now in the second <operand> put double quotes “PF and press ENTER

Imagem Blog UansCarvalho

In THEN click <Insert Action> and select assert new

Imagem Blog UansCarvalho

In <target> select Mensagem

Imagem Blog UansCarvalho

In <edit properties> by clicking the following screen will appear, then the Value tab put double quotes TIPO PESSOA FISICA, take a ENTER return and click OK

Imagem Blog UansCarvalho

We now define the rule for JURIDICA person and then a rule to case the person does not tell us either.

To facilitate our Rule we will copy and rename it

Next door to PessoaFisicaRule click the right mouse button and click Copy

Imagem Blog UansCarvalho

Now below THEN click Paste Rule

Imagem Blog UansCarvalho

Change the parameters as follows:

  • Rename Rule2 to PessoaJuridicaRule
  • In IF click again on PersonType and change to TipoPessoa.input
  • In “PF changes to PJ”
  • In THEN putTIPO PESSOA JURIDICA in result

You should then be as follows:

Imagem Blog UansCarvalho

Now again copy any of the rules and place the below leaving the screen as following parameters:

Imagem Blog UansCarvalho

So now we have the following three rules:

Imagem Blog UansCarvalho

So far OK, our Rules have already been defined.

Now go back to BusinessRuleBPELProcess.bpel and add an Assign after our receiveInput then rename it to TipoPessoaAssign

Imagem Blog UansCarvalho

Within our TipoPessoaAssign call our payload inputVariable (left side) to TipoPessoa (right side) and click OK

Imagem Blog UansCarvalho

Now drag another Assign below TipoPessoaRule and rename it to OutputAssign

Imagem Blog UansCarvalho

Open OutputAssign and within it call Mensagem (right side) to your outputVariable Payload (left side)

Imagem Blog UansCarvalho

Perform deploy locally of our project and we will test it

In your browser go to the address 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: BusinessRuleBpel [1.0]

Imagem Blog UansCarvalho

Click Test

Imagem Blog UansCarvalho

In input place eg PF and then click Test Web Service

Imagem Blog UansCarvalho

Below is the result:

Imagem Blog UansCarvalho

Do the test again putting on input PJ and then any other name

 

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

Leave a Reply

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