bpel arrays

Upload: anirudh-pandey

Post on 19-Feb-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 Bpel Arrays

    1/17

    bpel-104-Arrays

    bpel-104-ArraysThis sample illustrates how you can handle array structures present in your XML payloadusing the activity in the BPEL process. The Arrays ample BPEL Process

    receives Purchase !rder in"ormation as a XML payload consisting o" multiple line items.

    Each line item XML node consists o" uid# price# $uantity and the line%total. The o&'ectiveo" this sample is to illustrate how we can handle these multiple line%items and arrive at

    the total invoice price which is the sum o" all the line%total. The Arrays ample process

    uses two varia&les namely iterator and count along with activity to loop throughall the line%item nodes and come up with the invoice total.

    bpel-104-Arrays................................................................1

    1.Installing the sample......................................................2

    2.Description and Architecture..........................................3

    3.Running the sample.......................................................6

    4.uilding the sample.....................................................12

    !reate a "e# $%A !omposite Application................12

    !reate the Array$ample.#sdl &ile...........................13

    Add a '() 'rocess to the !omposite.....................13

    Add the '() "odes and Actions............................14

  • 7/23/2019 Bpel Arrays

    2/17

    bpel-104-Arrays

    1. Installing the sample(or instructions on installing this sample# open the "ollowing "ile in &rowser)SOASamples/bpel/bpel-104-Arrays/README.html

    -

  • 7/23/2019 Bpel Arrays

    3/17

    bpel-104-Arrays

    2. Description and ArchitectureThis sample shows how to process an array o" line items in an XML invoice document tocalculate the total amount o" an invoice. The architecture "or this sample is vary straight

    "orward. The "ollowing diagram shows the composite application structure.

    The client in the E*posed ervices swim%lane is &ased on the Arrayample.wsdl "ile#

    which de"ines a !AP we& service inter"ace to the Arrayample.&pel BPEL process. The

    BPEL process ta+es the XML invoice# analy,es each line item in the invoice to calculatethe total value o" the invoice. The BPEL process overview is shown ne*t.

    -3

  • 7/23/2019 Bpel Arrays

    4/17

    bpel-104-Arrays

    The "irstsetAttributenode at the top o" the process simply initiali,ed the iteratorandcountvaria&les that will &e used as the process loops through the line items o" the

    invoice. The whilenode contains a singlesetAttributenode that does the &ul+ o" the

    wor+. This secondsetAttributenode contains three copyactions as shown in the"ollowing ta&le.

    -opy (rom -opy To

    concat/0tns)invoice0tns)line%

    item1/#&pws)get2aria&le3ata/iterator/4#/50tns)line%total/4

    *path00

    &pws)get2aria&le3ata/input/#/payload/#&pws)get2aria&le3ata/*path/44 6

    &pws)get2aria&le3ata/input/#/payload/#/0tns)invoice0tns)total/4

    0tns)7invoice0tns)total

    &pws)get2aria&le3ata/iterator/4 6 8 iterator00

    The "irst copy action is used to create an XPath e*pression that points to the correct lineitem within the invoice "or the current iteration. The second copy action then used that

    -

  • 7/23/2019 Bpel Arrays

    5/17

    bpel-104-Arrays

    XPath e*pression to retrieve the line%item total# add it to the invoice total# and then

    update the invoice total with the new amount. The third and "inal copy action increments

    the iterator. The encompassing while node with then test the value o" the iterator againthe count varia&le to determine i" another iteration is needed.

    The last Assign node is the copyOutputwhich simply copies the updated invoice to the

    output varia&le so that it will &e returned to the caller via the call&ac+.

    -5

  • 7/23/2019 Bpel Arrays

    6/17

    bpel-104-Arrays

    3. Running the sampleTo run the sample# startup your !A uite admin server and the soa9server8 server. !nce&oth servers are up and running completely# use :3eveloper to deploy the application to

    the application server. !nce you have success"ully deployed the application# open a

    &rowser and point it to http)00localhost);80emto &ring up the !racle Enterprise

    Manager.!nce the Enterprise Manager page loads# navigate to the Arrayample application as

    shown in the "ollowing "igure and press the Test &utton.

    3epending on your con"iguration# there may &e a pro&lem parsing the =3L &ased onyour machine name# as shown in the "ollowing "igure. " this occurs# simply replace the

    machine name in the ?@L with localhost. The "ull ?@L is as "ollow)

    http)00localhost)C80soa%in"ra0services0de"ault0Arrayample0clientD=3LPress theParse&utton. The Enterprise Manager page will con"igure itsel" to provide you

    with a we& page that you can use "or testing the we& service. There will &e a @e$uest and

    a @esponse ta&. Ensure that the @e$uest ta& is selelcted and scroll to the &ottom part o"

    the we& page to "ill in the "ields in the nput Arguments section. (ill in each o" the "ields.

    The data in the "ields "or the ?3# Buyer# eller and the various address "ields are notvalidated other than to chec+ they they contain some data. ou are "ree to put random

    data into these "ields.n the line%item "ield you need to enter the num&er o" line items "or the order. Enter a

    value li+e F or G to +eep things simple at "irst. Then press the Arrayi,e icon to the

    immediate right o" the line%item "ield# as shown in the ne*t "igure.

    How you can "ill in the line items with your values. The "ollowing is a sample XMLdocument that contains all o" the "ields needed to run the test)

  • 7/23/2019 Bpel Arrays

    7/17

    bpel-104-Arrays

  • 7/23/2019 Bpel Arrays

    8/17

    bpel-104-Arrays

  • 7/23/2019 Bpel Arrays

    9/17

    bpel-104-Arrays

    ou can see "rom the audit trail that the whilenode in the BPEL process iterated G timesover the invoice# once "or each line item. " you have set the audit level toDevelopment#

    you can see the XML document that is returned# as shown in the ne*t "igure.

    -,

  • 7/23/2019 Bpel Arrays

    10/17

    bpel-104-Arrays

    -

  • 7/23/2019 Bpel Arrays

    11/17

    bpel-104-Arrays

    ou can ena&le development mode audit level &y right%clic+ing on thesoain!ra

    "soa#server$%entry in the le"t side o" the Enterprise Manager navigation &ar and

    selecting SOA A&ministration ' (ommon Properties"rom the popup menu. There youcan set the audit level. Be sure to press theApply&utton to save your changes to the audit

    level.

    -11

  • 7/23/2019 Bpel Arrays

    12/17

    bpel-104-Arrays

    4. Building the samplen this section we will descri&e how to create this sample "rom scratch. =e will notdescri&e each an every mouse clic+# &ut you should &e a&le to easily "ollow these

    instructions and wor+ out the minor details on your own. Iere are the high level steps in

    the construction process)

    1. Create a new SOA composite application

    2. Create the ArraySample.wsdl file

    3. Add a B!" process to the composite

    4. Add the B!" nodes and actions

    reate a !e" #$A omposite Application1. #rom the main men$% select File Newto brin& $p the 'ew (allery wi)ard.

    SelectApplicationsas the cate&ory and then select SOA Applicationas the specific

    type of application to create. ress the OKb$tton.

    2. *n the ne+t step of the wi)ard% enter a name for yo$r application. ress the Next

    b$tton

    3. !nter a name for yo$r pro,ect and press the Nextb$tton.

    4. *n the final step% select Empty Compositeas the composite template and press

    the Finishb$tton

    -

  • 7/23/2019 Bpel Arrays

    13/17

    bpel-104-Arrays

    reate the Array#ample."sdl %ileHow that the application and pro'ect are created# "ollow these steps)

    . Open the pro,ect yo$ created in the Application window top left part of the

    /eeloper *!

    . i&ht-clic on the SOA Content folder and select #ile 5 'ew

    6. *n the 'ew (allery dialo&% select the Generalcate&ory and then select the File

    item. ress the OKb$tton.

    7. 'ame the fileArraySample.wsdl and press the OKb$tton.

    8. *nstead of listin& the file contents here% simply copy the contents of the

    ArraySample.wsdl file from this sample pro,ect and paste the content into yo$r new

    ArraySample.wsdl file.

    Add a B&'( &rocess to the omposite

    10. #rom the Component alette% $nder the Serice Components headin&%clic and dra& a BPE Processcomponent onto the Components section of the

    composite.+ml file. 9his will brin& $p the Create B!" rocess wi)ard.

    11. *n the B!" rocess :i)ard% name the processArraySampleProcessand

    set the 9emplate field to Based on a !S".

    12. Select the ArraySample.wsdl file that yo$ created earlier in this pro,ect.

    13. Set the ort 9ype field toArraySample

    14. Set the Callbac ort 9ype field toArraySampleCall#ac$

    -13

  • 7/23/2019 Bpel Arrays

    14/17

    bpel-104-Arrays

    1. ;o$r dialo& sho$ld closely match the one shown in the ne+t fi&$re. ress

    the OKb$tton.

    Add the B&'( !odes and ActionsAt this point# your composite.*ml "ile should loo+ li+e the "ollowing)

    1. o$ble-clic on theArraySampleProcessB!" node to open $p the

    B!" process for editin&.

    16. Create the iterator% co%ntandxpathariables by clicin& on the ariables

    b$tton in the B!" process to brin& $p the

  • 7/23/2019 Bpel Arrays

    15/17

    bpel-104-Arrays

    17. ename the e+istin& inp%t(aria#leand o%tp%t(aria#leariables to inp%tand o%tp%trespectiely.

    18. ress the OKb$tton after yo$ hae created all 3 ariables.

    20. ra& and drop andAssi'nactiity from the Component alette between

    the recei)e*np%tand call#ac$Clientnodes in the B!" process flow.

    21. 'ame the new Assi&n action to *nitiali+e(aria#les.

    22. o$ble-clic the *nitiali+e(aria#lesactiity to edit it.

    23. Create 2 Copyactions as depicted in the followin& table

    -opy (rom -opy To

    8 iterator00

    ora)countHodes/input/# /payload/#/0tns)invoice0tns)line%item/4 count00

    24. 'ow dra& and drop a whileactiity from the Component alette directly

    below the *nitiali+e(aria#lesnode.

    -15

  • 7/23/2019 Bpel Arrays

    16/17

    bpel-104-Arrays

    2. "abel the whileactiity >iterator ?@ co$nt

    2. Open the whileactiity by clicin& on it > b$tton

    26. ra& and drop anAssi'nactiity into the whileactiity.

    27. 'ame the Assi&n actiity to Calc,otal

    28. Open the Calc,otalactiity and create three Copyactions as shown in the

    followin& table.

    -opy (rom -opy To

    concat/0tns)invoice0tns)line%

    item1/#&pws)get2aria&le3ata/iterator/4#/50tns)line%total/4

    *path00

    &pws)get2aria&le3ata/input/#/payload/#&pws)get2aria&le3ata/*

    path/44 6

    &pws)get2aria&le3ata/input/#/payload/#/0tns)invoice0tns)total/4

    0tns)7invoice0tns)total

    &pws)get2aria&le3ata/iterator/4 6 8 iterator00

    30. *n the B!" rocess esi&ner% close the whileactiity to hide the action it

    contains.

    31. ra& and drop a newAssi'nactiity directly below and o$tside of the

    whileactiity. 'ame this actiity copyO%tp%t

    32. Open the copyO%tp%tactiity and add a sin&le copyaction. ;o$r copy

    action sho$ld loo lie the followin&D

    -

  • 7/23/2019 Bpel Arrays

    17/17

    bpel-104-Arrays

    ave your wor+ and deploy it and test itJ

    -1