This discussion is archived
4 Replies Latest reply: Jan 25, 2013 9:19 PM by oracleistheway RSS

Assigning multiple nodes problem

oracleistheway Newbie
Currently Being Moderated
Hi everyone. I am new to the Oracle SOA Suite and I am using release 11g. Here is what I am trying to accomplish -

I have an element of with multiple nodes (carTypes) and within that I have the car's color, year, and make. I loop through the array and try to assign only cars within a year range so that the response will show all the nodes of those years. But, the only carType node within in year range that shows in the response is the last node in the range.

For example, I have have 3 car years that are within range so the response should show -
<car-root>
<carType>
<name>Ram</name>
<color>Red</color>
<year>2000</year>
<make>Dodge</make>
</carType>
<carType>
<name>Carrola</name>
<color>Black</color>
<year>2001</year>
<make>Toyota</make>
</carType>
<carType>
<name>Malibu</name>
<color>Blue</color>
<year>2002</year>
<make>Chevy</make>
</carType>
</car-root>

But...
It only shows the last one -
<carType>
<name>Malibu</name>
<color>Blue</color>
<year>2002</year>
<make>Chevy</make>
</carType>
</car-root>

Looking at the trace It looks like it is just overwriting the node instead of making multiple nodes.

How do I have it create multiple nodes so that I can get the response showing all cars within range?

Thanks for taking a look.

Edited by: 984188 on Jan 25, 2013 3:00 PM
  • 1. Re: Assigning multiple nodes problem
    983647 Explorer
    Currently Being Moderated
    Use a Transformation and use a "For Each" to loop through the all the CarType and and use a "if" to filter out the records you want.

    Look at the Example 40-3 for-each Construct
    -- http://docs.oracle.com/cd/E28271_01/dev.1111/e10224/bp_xslt_mpr.htm#sthref3090

    --
    Mark the posting appropriately, as "Helpful", "Correct Answer", if your issue is resolved.
  • 2. Re: Assigning multiple nodes problem
    oracleistheway Newbie
    Currently Being Moderated
    Hi thanks for the reply.

    That worked! Now I am trying build a nodelist to respond with the carTypes that were not in the range. I put the while loop in Scope and attached a CatchAll to it. If the car year is not in range I throw a fault. In the catch all is where I want to build the nodelist of cars not selected. Now those elements seem to be getting overwritten. This seems so much easier to accomplish in regular Java which is what makes this so frustrating.
  • 3. Re: Assigning multiple nodes problem
    983647 Explorer
    Currently Being Moderated
    I am beleiving that your requirement is
    1) To reply back with all the CarTypes that are in a given range, then reply back with the list
    2) Otherwise reply back with the a fault that contains all the CarTypes that are not in the given range.

    If that is the case:

    Then to implement "part (1)" you already have solution. For "part (2)" create another vairable 'tempVariable' and collect all the CarTypes again, simillary to what you did for the step 1, using For Each an If , however, this time the condition for the if will be the opposite of previous one.

    Finally, before replying, check the contents of the 'tempVariable', if it not empty reply with fault otherwise give the proper reply.

    P.S.:While loop in BPEL is costly, use the costructs like while, if they are mandatory and not avoidable (Don't use them as you would use in OO/procedural languages)

    --
    Mark the posting appropriately, as "Helpful", "Correct Answer", if your issue is resolved.
  • 4. Re: Assigning multiple nodes problem
    oracleistheway Newbie
    Currently Being Moderated
    I believe I did what you suggested before you suggested it.

    while loop goes through the list node
    if carType/caryear[index] > carrange
    throw fault

    catch fault
    <assign>
    concat all caryears[index] not in range to tmpFault variable
    </assign>
    end while
    <switch condition if tmpFault.length > 0>
    <transform>
    for each
    if tmpFault.contains(caryear)
    assign values
    </transform>
    </switch>

    Hopefully you get the logic. If so, does that seem like an okay solution?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points