2 Replies Latest reply: Oct 17, 2013 1:25 PM by Eric Elzinga RSS

    Dynamic variable in oracle service bus

    1048415

      I have for-each loop in OSB. In this loop I am calling business service. I have to store response somewhere so that I can use it whenever i required.

      means suppose loop will run 3 times i have to store all three responses different place or different variable so that I can use it later.

       

      Please help me on this requirement. its urgent.

        • 1. Re: Dynamic variable in oracle service bus
          paddys

          Define a schema for the result and a "list" type that is zero or many of the result types. You can then define a variable of the list type and add to it each time round the loop:

           

          <ns:ResultList>
             <ns:Result>
                 ...
             </ns:Result>
             <ns:Result>
                 ...
             </ns:Result>
          ...
          </ns:ResultList>
          

           

          You can get fancier, adding in metadata about which loop the result came from but that should cover you for a wide variety of needs.

           

          Paddy

          • 2. Re: Dynamic variable in oracle service bus
            Eric Elzinga

            you could do something like this

             

            assign <resultlist/> to variable $myList

            then in the looping use the insert activity to do something like

            expression = <myresultelement>

            location=as first child of resultlist

            xpath = ./*

            in variable = .resultlist

             

            or

            in the looping do something like :

            replace ./* in variable mylist with concat(mylist,'<newresultelement>eee</newresultelement>')

             

            after the looping you will have something like this

             

            <newresultelement>eee</newresultelement>

            <newresultelement>xxx</newresultelement>

            <newresultelement>aaa</newresultelement>

            <newresultelement>bbb</newresultelement>

             

            then do another replace/assing with

             

            ./* in mylist with <resultlist>{$mylist}</resultlist>

            now we also have the root-element for the list

             

             

            so..just some thoughts on how to achieve it