Topic
26 replies Latest Post - ‏2013-07-19T13:55:03Z by DataPowerDev
metroplex
metroplex
26 Posts
ACCEPTED ANSWER

Pinned topic How to access current context of for-each from "loop action" Action?

‏2011-06-24T19:06:45Z |
I've looked the forums over in addition to the DP documentation but I haven't been able to find an answer to the following question, hopefully someone can help;

Here's the scenario:

-I define a for-each Action on a processing rule that loops through an XML document based on an XPATH expression.
-I then define an Action to be kicked off for every iteration of that loop.

Here's the question:

How do I access the nodes that were selected by the for-each loop (via the XPATH expression) for each iteration by the Action that's targeted to execute each time? I know how to do it in a stylesheet (via use of the var://service/multistep/loop-iterator variable) but how do I get this info to say, a conditional Action?

Using the output context of the for-each Action as the input context of the targeted Action doesn't seem to work. Nor does specifying AUTO, INPUT or the loop-iterator variable (which would make a lot of sense to be able to do it that way).

I should also add that my for-each is asynch and it creates multiple outputs. Perhaps what I am trying to accomplish cannot be done with merely Actions and will require the use of a stylesheet.

Thanks in advance for any help.
Updated on 2011-07-05T13:37:20Z at 2011-07-05T13:37:20Z by metroplex
  • swlinn
    swlinn
    1330 Posts
    ACCEPTED ANSWER

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-24T20:41:23Z  in response to metroplex
    The conditional action requires you to xpath across a document provided in the input context to the conditional action. Unfortunately, having dp:variable('var://service/multistep/loop-iterator') ... or any other DataPower extension function, is not permitted. Thus you need to have a stylesheet that would output the loop-iterator node to an output context that could then be used by your conditional action, if that is what you really wanted to do.

    As far as the output context of the for-each, quite frankly, I've never tried to see the output. I was more interested in the output context of the multiple actions driven through the for-each action, which would be a different context than the input/output of the for-each action anyway. For example, I have used this to run multiple transformations where the stylesheets to be run were in the input context to the for-each, and the transformation action took an initial data context as input as used the same context as its output. It was somewhat like piping the data through multiple transformation actions, but the context had the end result when it was all finished.

    You say the for-each is asynchronous. That would tell me that the for-each iteration doesn't hold up the subsequent actions on your rule. Hopefully you have an event sync in your rule at some point?? As for the actual actions being done in the for-each, you can only specify the input context and output context one time in the configuration, so when you say you are generating multiple outputs, how are you doing that? Are you saving your output of each transformation to a context variable that is uniquely named (var://context/myoutputx where x is the loop iterator count?) It will be helpful if you can give some more detail of what you are trying to do.

    Regards,
    Steve
    • metroplex
      metroplex
      26 Posts
      ACCEPTED ANSWER

      Re: How to access current context of for-each from "loop action" Action?

      ‏2011-06-24T21:17:49Z  in response to swlinn
      Hey Steve, thanks for the reply, sincerely. I'll answer your questions/clarify below (your comments are underlined);

      The conditional action requires you to xpath across a document provided in the input context to the conditional action. Unfortunately, having dp:variable('var://service/multistep/loop-iterator') ... or any other DataPower extension function, is not permitted.

      Yes, I understand this, that the for-each operates on an incoming XML document specified by the input context. As such, I have the document that I want to "loop" over going into the for-each; no worries here. What I want to do to the document is to loop through all of the FOO nodes and then have an Action operate on each one of those nodes. Therefore I have specified an Action to be triggered per each iteration, it just so happens that the Action I want triggered is a conditional.

      In order to execute the conditional, I need to have access to the FOO node that was "torn" out of the original document by the XPATH expression of the for-each Action. I'm asking how I get access to the specific FOO node for each iteration so that I can evaluate my conditional against it. If I were to use a stylesheet (because I selected a TRANSFORM Action in my for-each Action as opposed to a CONDITIONAL action) then I could simply use the 'var://service/multistep/loop-iterator' variable. However, I'd rather just pump each FOO node right into the conditional Action.

      As I mentioned before, I tried setting the input context of the conditional to the 'var://service/multistep/loop-iterator' variable as it would make sense that since the XPATH used by the for-loop would tear off the FOO node that I could just route that nodeset into the input of the conditional. However, no luck here.

      You say the for-each is asynchronous. That would tell me that the for-each iteration doesn't hold up the subsequent actions on your rule. Hopefully you have an event sync in your rule at some point??

      Yep, no doubt, I sync a number of asynch Actions before I combine everything together at the end. I indicated that it was asynch because sometimes that has bearing on what output contexts things have to be stored to; didn't know if it made any difference here.

      ... you can only specify the input context and output context one time in the configuration, so when you say you are generating multiple outputs, how are you doing that?

      While it's true that you can only set a single output context for a for-each Action you can also indicate that you want to use multiple outputs. When you do this then every iteration of the for-each Action creates a new output context named by using the value you supplied as the output context as a template. So, for example, if I set the output context to "LOOP_OUT_ITERATION" then for each iteration of my for-each an output context will be created called "LOOP_OUT_ITERATION_X" where X is the iteration number of the current loop.

      Hope this helps clarify things.

      thanks again.
      • Liv2luv
        Liv2luv
        573 Posts
        ACCEPTED ANSWER

        Re: How to access current context of for-each from "loop action" Action?

        ‏2011-06-25T13:12:48Z  in response to metroplex
        Not sure if I've followed the discussion in its true sense...

        >In order to execute the conditional, I need to have access to the FOO node that was "torn" out of the original document by the XPATH expression of the for-each Action. I'm asking how I get access to the specific FOO node for each iteration so that I can evaluate my conditional against it.

        In the preceding xform action, I would try to take the FOO node into a context variable and access the same in the loop Action stylesheet for conditional processing.

        Thanks.
        • metroplex
          metroplex
          26 Posts
          ACCEPTED ANSWER

          Re: How to access current context of for-each from "loop action" Action?

          ‏2011-06-27T13:04:07Z  in response to Liv2luv
          Liv2Luv, thanks for your reply, you stated;

          >In the preceding xform action, I would try to take the FOO node into a context variable and access the same in the loop Action stylesheet for conditional processing.

          Unfortunately the XFORM that is doing this work IS the for-each. That's my question, by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

          I've been disappointed (with the device) at this point that I can't seem to use it without dropping to a stylesheet. Again, maybe I'm just missing the proper way to configure it?

          thanks.
          • Liv2luv
            Liv2luv
            573 Posts
            ACCEPTED ANSWER

            Re: How to access current context of for-each from "loop action" Action?

            ‏2011-06-27T16:11:22Z  in response to metroplex
            Hi,

            >...by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

            How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

            Further, see the attached sample loopback XML firewall to understand if there is any gap between our understanding. Input for the object is:

            
            <?xml version=
            "1.0" encoding=
            "UTF-8"?> <joe:Order xmlns:joe=
            "http://joe.com"> <joe:metaInfo> <joe:itemCount>4</joe:itemCount> <joe:minquantity>10</joe:minquantity> </joe:metaInfo> <joe:Item> <joe:Qty>5</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>7</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>9</joe:Qty> <joe:ProdID>78-697-24</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>12</joe:Qty> <joe:ProdID>091356-3</joe:ProdID> </joe:Item> </joe:Order>
            


            processing flow:

            INPUT xform1 PIPE -> PIPE For-each(contains LoopAction xform2) dpvar -> NULL xform3 PIPE -> PIPE Results

            Multiple-outputs for For-each action is ON

            xform1 = joe-meta-info-node.xsl
            xform2 = pseudo-for-each-logic.xsl
            xform3 = joe-final-order-combiner.xsl

            joe-meta-info-node.xsl
            This stylesheet takes the <joe:metaInfo> nodeset into a context variable

            pseudo-for-each-logic.xsl
            1. If condition verifies the loop happens upto the # of times of the <joe:itemCount> element's value
            2. If <joe:minquantity> element's value is less than the <joe:Qty> element's value; do-something...
            3. Otherwise consider as a valid order quantity and copy it further

            joe-final-order-combiner.xsl
            copies metaInfo and valid orders as an output.

            Thanks.
            • Liv2luv
              Liv2luv
              573 Posts
              ACCEPTED ANSWER

              Re: How to access current context of for-each from "loop action" Action?

              ‏2011-06-27T16:12:22Z  in response to Liv2luv
              here is the attachment.
            • metroplex
              metroplex
              26 Posts
              ACCEPTED ANSWER

              Re: How to access current context of for-each from "loop action" Action?

              ‏2011-06-27T16:50:04Z  in response to Liv2luv
              Liv2luv, again, thanks for your reply. From your response;

              > How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

              Yes, I can get it to work like this. When I involve a stylesheet then I can directly access the loop-iterator variable. What I was hoping for was to be able to do it via just the built in Actions so that the flow represents visually via the GUI what's going on.

              Here's a detailed example to help me explain further. Again, in my opinion the devices should be able to handle something like this without having to use a XFORM.

              Here's the XML that comes into the for-each loop:

              <COMPANY>
              <PRODUCT>
              <FOO>
              </FOO>
              </PRODUCT>
              </COMPANY>
            • metroplex
              metroplex
              26 Posts
              ACCEPTED ANSWER

              Re: How to access current context of for-each from "loop action" Action?

              ‏2011-06-27T17:14:22Z  in response to Liv2luv
              (PLEASE DISREGARD MY RESPONSE DIRECTLY ABOVE THIS ONE - IT WAS UNFINISHED WHEN THE BROWSER SUBMITTED IT, SORRY)

              Liv2luv, again, thanks for your reply. From your response;

              > How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

              Yes, I can get it to work like this. When I involve a stylesheet then I can directly access the loop-iterator variable. What I was hoping for was to be able to do it via just the built in Actions so that the flow represents visually via the GUI what's going on.

              Here's a detailed example to help me explain further. Again, in my opinion the devices should be able to handle something like this without having to use a XFORM.

              Here's an example XML that comes into the for-each loop:

              <COMPANY>
              <PRODUCT>
              <FOO>
              <ID>1</ID>
              <FEATURE>HOT</FEATURE>
              </FOO>
              <FOO>
              <ID>2</ID>
              <FEATURE>WARM</FEATURE>
              </FOO>
              <FOO>
              <ID>3</ID>
              <FEATURE>COLD</FEATURE>
              </FOO>
              </PRODUCT>
              </COMPANY>

              I can have many <FOO> items so I use the XPATH expression //FOO to force the for-each to iterate through each one. As the for-each iterates through each one it places each <FOO> node set into the var://service/multistep/loop-iterator variable. So, the variable will hold the following values (once per each iteration);

              ITERATION 1:
              <FOO>
              <ID>1</ID>
              <FEATURE>HOT</FEATURE>
              </FOO>

              ITERATION 2:
              <FOO>
              <ID>2</ID>
              <FEATURE>WARM</FEATURE>
              </FOO>

              ITERATION 3:
              <FOO>
              <ID>3</ID>
              <FEATURE>COLD</FEATURE>
              </FOO>

              I realize that I can grab these through a stylesheet, however, the for-each allows me to specify an Action to kick off for each iteration (other than a XFORM). What I'd like to do is to specify a conditional Action that looks at the <FEATURE> node of each independent <FOO> node as it's iterated on. I want to do something different based on whether it's HOT, WARM or COLD.

              My question is, can I get the currently iterated node into a conditional (or other) Action without having to "shell" out to a stylesheet? I would think that access to the currently iterated node would seem to be the entire point of a for-each Action. The fact that the for-each allows you to specify essentially any other Action as one that gets "executed" for each iteration leads me to believe that we should be able to just "pipe" the input info from the current for-each iteration into the per iteration Action.

              I realize that there are other work arounds and I truly appreciate the samples that have been posted in this thread. I guess I'm just expecting that devices of this caliber should be able to do this sort of thing trivially. By moving the logic into a stylesheet and away from the GUI the flow for the rule is getting buried (in my opinion).

              thanks.
              • Liv2luv
                Liv2luv
                573 Posts
                ACCEPTED ANSWER

                Re: How to access current context of for-each from "loop action" Action?

                ‏2011-06-27T18:35:26Z  in response to metroplex
                Hi,

                >My question is, can I get the currently iterated node into a conditional (or other) Action without having to "shell" out to a stylesheet?

                Yes. I've done it this way...If you're modifying the existing For-each action:

                1. double click on For-each action
                2. Click on Loop action hyperlink
                3. Click on advanced tab of configure transform action
                4. select the dropdown as conditional for action type
                5. Apply the relative Xpath (/FOO/FEATURE​&​#8203;text()=HOT​&​#8203;)for var://service/multistep/loop-iterator nodeset
                6. Apply a stylesheet for each different feature :)

                If you are routing various Feature nodesets... then route action (based on xpath) would be most appropriate and there will be no stylesheets to write.

                Thanks.
                • Liv2luv
                  Liv2luv
                  573 Posts
                  ACCEPTED ANSWER

                  Re: How to access current context of for-each from "loop action" Action?

                  ‏2011-06-27T18:45:46Z  in response to Liv2luv
                  For:
                  ​&​#8203;text()=HOT​&​#8203;

                  Read this as:
                  left square bracket text()=HOT right square bracket

                  Thanks.
                  • metroplex
                    metroplex
                    26 Posts
                    ACCEPTED ANSWER

                    Re: How to access current context of for-each from "loop action" Action?

                    ‏2011-06-27T20:14:23Z  in response to Liv2luv
                    Ok, great thx for the confirmation. This is actually what I had done originally (expecting it to work) but it failed. The context that the conditinal was executing against was the whole incoming XML document and not the nodes that would have been rendered for each iteration by the for-each XPATH.

                    At least I know it's possible now so I'll continue to look into why it's not working for me.

                    thanks again.
                    • swlinn
                      swlinn
                      1330 Posts
                      ACCEPTED ANSWER

                      Re: How to access current context of for-each from "loop action" Action?

                      ‏2011-06-27T20:46:43Z  in response to metroplex
                      Catching up on this thread ... so what then is the input context to the conditional action in this solution proposed above? I think that was the original question which I don't see in the six point instructions and what I still don't believe is possible. I've seen for-each used for transformations where the for-each input had a number of <xsl>local:///blah.xsl</xsl> nodes, result actions where the for-each input had a number of <uri>http://host:port/blah</uri>, and I even kludged in a call action where the input to the for-each had the names for other processing rules in the service (you have to configure that on the processing action accessed from the object menu). The for-each action places each iteration in the loop-iterator service variable for the loop action to refer to as part of its configuration, so how will the conditional action access it? You can't specify a context variable for an input context to my knowledge, and you can't use it in the xpath config of the conditional action. Maybe I'm missing something here?? I did miss the multiple outputs on the for-each action in my earlier post, thanks for pointing that out.

                      Regards,
                      Steve
                      • swlinn
                        swlinn
                        1330 Posts
                        ACCEPTED ANSWER

                        Re: How to access current context of for-each from "loop action" Action?

                        ‏2011-06-27T21:03:12Z  in response to swlinn
                        So let me ask another way. I can see you want //foo determining different processing. What do you want your conditional to look like? Ie, for each value of foo, what do you want to do? Perhaps understanding that will lead to a solution.

                        Regards,
                        Steve
                        • metroplex
                          metroplex
                          26 Posts
                          ACCEPTED ANSWER

                          Re: How to access current context of for-each from "loop action" Action?

                          ‏2011-06-28T13:35:05Z  in response to swlinn
                          Steve, thx for the reply, you asked;

                          > ... so what then is the input context to the conditional action in this solution proposed above? I think that was the original question which I don't see in the six point instructions and what I still don't believe is possible.

                          Yes, this is what I was asking ... as I've tried all sorts of things. What baffles me is that the intent of the for-each is to deconstruct an incoming XML into smaller "node" subsets for iterative processing but I can't seem to find a way to access those smaller units directly from another Action. It's weak, in my opinion, that the only way to access the iteration data is via a stylesheet to the exclusion of all of the other built in Action types.

                          > The for-each action places each iteration in the loop-iterator service variable for the loop action to refer to as part of its configuration, so how will the conditional action access it? You can't specify a context variable for an input context to my knowledge, and you can't use it in the xpath config of the conditional action.

                          This is where it would make sense (in my opinion) to be able to specify the loop-iterator variable for any contained Actions by the for-each to indicate that you want that Action to use the current iteration of the for-each loop. Again, I've tried this but to no avail.

                          > So let me ask another way. I can see you want //foo determining different processing. What do you want your conditional to look like? Ie, for each value of foo, what do you want to do? Perhaps understanding that will lead to a solution.

                          To continue with the <FOO> example that I added in a prior post; the for-each processes each individual <FOO> nodeset and then the conditional Action is designed to act on the <FEATURE> node contained within to do something different on whether it's HOT, COLD, WARM, etc.

                          I know that I can get it to work via other mechanisms; stylesheets, etc. but I'd rather do it with the built in Actions and was looking for confirmation that the devices could/couldn't do it and that perhaps I was just configuring it incorrectly.

                          thanks.
                          • swlinn
                            swlinn
                            1330 Posts
                            ACCEPTED ANSWER

                            Re: How to access current context of for-each from "loop action" Action?

                            ‏2011-06-28T19:55:00Z  in response to metroplex
                            Hi Adam,

                            The design point of the for-each was to place the found node set into the service variable where that service variable could be used in the loop action. It is a very powerful action when the loop action is result, result-async, transformation, binary-transformation, fetch, and call actions for example where the specific requirement of that loop action, ie, a destination url or url to a file, could be specified by a variable. The conditional action only has within the action an XPath that acts against its input context, but that isn't what you want in your use case. We're in agreement here, I would love to have the ability, within a conditional action, to specify an XPath like dp:variable('var://service/multistep/loop-iterator')/foo/whatever = 'hot' for example, instead of always relying on the INPUT context alone, but that would be an enhancement request to the product. I'd suggest you discuss the requirement with your DataPower tech sales rep to get that request documented.

                            In the mean time, one option I can think of would be for you to have your for-each action use a call action to call a specific rule, the first transformation of that rule could simply output the loop iterator variable node set for that iteration and the conditional action could then use that output as input to do what you are trying to do.

                            Regards,
                            Steve
                            • swlinn
                              swlinn
                              1330 Posts
                              ACCEPTED ANSWER

                              Re: How to access current context of for-each from "loop action" Action?

                              ‏2011-06-28T19:56:20Z  in response to swlinn
                              No idea how my response to another thread became a thread of its own ... please disregard ... I'll paste a new response into the appropriate thread.

                              Steve
                              • swlinn
                                swlinn
                                1330 Posts
                                ACCEPTED ANSWER

                                Re: How to access current context of for-each from "loop action" Action?

                                ‏2011-06-28T19:57:18Z  in response to swlinn
                                LOL ... not my day ... I'm the first post on page 2, not a new thread ... Steve
  • metroplex
    metroplex
    26 Posts
    ACCEPTED ANSWER

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-07-05T13:37:20Z  in response to metroplex
    Thanks for your help.
    • swlinn
      swlinn
      1330 Posts
      ACCEPTED ANSWER

      Re: How to access current context of for-each from "loop action" Action?

      ‏2013-07-15T21:32:40Z  in response to metroplex

      So if I understand the question, you're in the loop action which may have context "Loop", but the for-each action is iterating over context "For-each" and you wish to have access to the for-each context while in loop action.  If you're loop action is a transformation action, you can do this a couple ways.  First, the node that matched is in var://service/multistep/loop-iterator, so in your stylesheet, you can xpath up or down the tree to get to the node you want, for example, select=".." would get you the parent of the node that matched.  Another approach would be to set a variable to the contents of  var://context/for-eachcontext by using a xsl:copy-of, but in that case, you don't have the specific reference of where you are in the for-each document.

      Regards,

      Steve

  • DataPowerDev
    DataPowerDev
    10 Posts
    ACCEPTED ANSWER

    Re: How to access current context of for-each from "loop action" Action?

    ‏2013-07-11T02:22:01Z  in response to metroplex

    Hello Experts,

    Urgent help needed.

    Hi all

    I've one requirement and I'd need to utilize for-each and event sink actions.

    firslty conditional action

    i) Bonuses and RedemptionTier node is present

    route it to one backend ( consider Bonuses==>serverA and RedemptionTier==>serverB )

    ii) if this is not present it needs to be routed to ServerC

    iii) Once some values are retrived for i it needs to be sent to final backend ( serverD = final )

    Sample request:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <s:Header/>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <ClaimRequest xmlns="http://xxxxx.com/xsd">
                <!--optional-->
                <Bonuses>
                    <!--Zero or more repetitions:-->
                    <Bonus>
                        <BonusCode>bc123</BonusCode>
                        <BonusType>C</BonusType>
                        <ShortDesc>?</ShortDesc>
                    </Bonus>
                    <Bonus>
                        <BonusCode>dd346</BonusCode>
                        <BonusType>M</BonusType>
                        <ShortDesc>?</ShortDesc>
                    </Bonus>
                </Bonuses>
                <!--Optional:-->
                <RedemptionTier>
                    <AwardID>awid456</AwardID>
                    <Amount>125.00</Amount>
                    <key>k1</key>
                </RedemptionTier>
                <BillingInfo>
                    <transmissionType xmlns="">Claim</transmissionType>
                    <transactionId xmlns="">922010161</transactionId>
                    <businessUnit xmlns="">2</businessUnit>
                    <transactionType xmlns="">C</transactionType>
                    <serviceRenderedFlag xmlns="">N</serviceRenderedFlag>
                    <transactionBillToType xmlns="">01</transactionBillToType>
                    <storeNumber xmlns="">undefined</storeNumber>
                    <businessDate xmlns="">2011-10-17T00:00:00-05:00</businessDate>
                </BillingInfo>
            </ClaimRequest>
        </s:Body>
    </s:Envelope>
     

    for each bonus we form the below request and sent to serverA

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://tempuri.org/" xmlns:tem="http://schemas.datacontract.org/2004/07/Claims">
        <soap:Header>
     </soap:Header>
        <soap:Body>
            <ns3:GenClaimsRequest>
                <ns3:request>
                    <tem:Bonus>
                        <tem:BonusCode>bc123</tem:BonusCode>
                        <tem:BonusType>C</tem:BonusType>
                        <tem:ShortDesc>?</tem:ShortDesc>
                    </tem:Bonus>
                </ns3:request>
            </ns3:GenClaimsRequest>
        </soap:Body>
    </soap:Envelope>

    In the response we'll get  get the points earned

    ( in future we'll retrieve more data )

    Response we get from serverA

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://tempuri.org/" xmlns:tem="http://schemas.datacontract.org/2004/07/Claims">
        <soap:Header/>
        <soap:Body>
            <ns3:genClaimsResponse>
                <ns3:request>
                    <tem:Bonus>
                        <tem:BonusCode>bc123</tem:BonusCode>
                        <tem:BonusType>C</tem:BonusType>
                        <tem:PointsEarned>1200</tem:PointsEarned>
                    </tem:Bonus>
                </ns3:request>
            </ns3:genClaimsResponse>
        </soap:Body>
    </soap:Envelope>
     

    Similarly we'll send the redemptionter request to serverB

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://tempuri.org/" xmlns:tem="http://schemas.datacontract.org/2004/07/Claims">
        <soap:Header/>
        <soap:Body>
            <ns3:getAccountIDRequest>
                <tem:RedemptionTier>
                    <tem:AwardID>awid456</tem:AwardID>
                    <tem:Amount>125.00</tem:Amount>
                    <tem:key>k1</tem:key>
                </tem:RedemptionTier>
            </ns3:getAccountIDRequest>
        </soap:Body>
    </soap:Envelope>
     

    We 'll retrieve accountID from ServerB

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://tempuri.org/" xmlns:tem="http://schemas.datacontract.org/2004/07/Claims">
        <soap:Header/>
        <soap:Body>
            <ns3:getAccountIDResponse>
                <tem:RedemptionTier>
                    <tem:AccountID>12324352346</tem:AccountID>
                </tem:RedemptionTier>
            </ns3:getAccountIDResponse>
        </soap:Body>
    </soap:Envelope>
     

    Then the final request will be sent to servreD by putting these values in the original request

    pointsEarned will be places as is

    but in redemptionTier only accountID is sent

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <s:Header/>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <ClaimRequest xmlns="http://xxxxx.com/xsd">
                <!--optional-->
                <Bonuses>
                    <!--Zero or more repetitions:-->
                    <Bonus>
                        <BonusCode>bc123</BonusCode>
                        <BonusType>C</BonusType>
                        <PointsEarned>1200</PointsEarned>
                        <ShortDesc>?</ShortDesc>
                    </Bonus>
                    <Bonus>
                        <BonusCode>dd346</BonusCode>
                        <BonusType>M</BonusType>
                        <PointsEarned>32</PointsEarned>
                        <ShortDesc>?</ShortDesc>
                    </Bonus>
                </Bonuses>
                <!--Optional:-->
                <RedemptionTier>
                    <AccountID>12324352346</AccountID>
                </RedemptionTier>
                <BillingInfo>
                    <transmissionType xmlns="">Claim</transmissionType>
                    <transactionId xmlns="">922010161</transactionId>
                    <businessUnit xmlns="">2</businessUnit>
                    <transactionType xmlns="">C</transactionType>
                    <serviceRenderedFlag xmlns="">N</serviceRenderedFlag>
                    <transactionBillToType xmlns="">01</transactionBillToType>
                    <storeNumber xmlns="">undefined</storeNumber>
                    <businessDate xmlns="">2011-10-17T00:00:00-05:00</businessDate>
                </BillingInfo>
            </ClaimRequest>
        </s:Body>
    </s:Envelope>

    we can wait on them while we retireve points earned and account# (as we move forward we'll plan to send and retrieve more values )

    Thank you in advance!.

    • DataPowerDev
      DataPowerDev
      10 Posts
      ACCEPTED ANSWER

      Re: How to access current context of for-each from "loop action" Action?

      ‏2013-07-11T15:06:30Z  in response to DataPowerDev

      Hello Experts,

      I haven't used for-each and event sync option can someone help me with this. It is urgent. Thank you in advance!.

      • DataPowerDev
        DataPowerDev
        10 Posts
        ACCEPTED ANSWER

        Re: How to access current context of for-each from "loop action" Action?

        ‏2013-07-15T17:35:06Z  in response to DataPowerDev

        Herman/Steve, Can you help me with this ?.

        Can some assist me with this requirement.

        This is urgent.

        thank you in advance!

        • swlinn
          swlinn
          1330 Posts
          ACCEPTED ANSWER

          Re: How to access current context of for-each from "loop action" Action?

          ‏2013-07-15T21:43:03Z  in response to DataPowerDev

          So if I understand what you're requesting, you want to iterate over your initial request and build multiple requests depending upon the nodes in the request (bonus/redemption).  Why not do all of that in a stylesheet, use xsl:for-each where you would build your serverA or serverB requests and send it to those backends using url-open, and you could aggregate those responses to form the final request that is sent to your backend?  Perhaps I am reading more into what you want to do, but it would seem to be more difficult to do this in multiple processing actions than it would in a transformation.  You could also have one transformation build a structure as you iterate over your initial request that would be placed into a context variable used by a result action with a destination url that used that context variable and placed each output into a separate context, and then have a 2nd transformation to aggregate the multiple responses, but all that would do is remove you having to do the url open code.  If it were me, I'd do the first approach.

          Regards,

          Steve

           

          • DataPowerDev
            DataPowerDev
            10 Posts
            ACCEPTED ANSWER

            Re: How to access current context of for-each from "loop action" Action?

            ‏2013-07-16T15:40:32Z  in response to swlinn

            Hi Steve,

            Thak you for your reply!.

            We've started with this basic service and looking at the roadmap of this service we believe for-each action which is more powerful. That was the reason why we've to choose this action over xslt. The service already been improved after having it migrated from other integartion tools ( do not want to mention them :) ) .

            http://publib.boulder.ibm.com/infocenter/wsdatap/v1r0m0/index.jsp?topic=%2Fcom.ibm.dp.xe.doc%2Fwebserviceproxydevelopersguide.xe82134.htm

            for-each and event sink as we develop this service ( with more add-ons ) and can even divide the required number of attibutes within bonus/redemption and then wiat on the responses from all the required backend servers.

            But we haven't worked much with this action making us feel handicapped ( still exploring these various appliances).

            Can you guys help us with this approach ?.

            • swlinn
              swlinn
              1330 Posts
              ACCEPTED ANSWER

              Re: How to access current context of for-each from "loop action" Action?

              ‏2013-07-16T17:09:21Z  in response to DataPowerDev

              Ok, so this is somewhat of design off of the cuff ...

              So the for-each action will iterate over a node set that you provide and will take some action for each iteration.  In your case, you can iterate over your request, looking for xpath of /*[local-name() = 'Envelope']/*[local-name() = 'Body']/ClaimRequest/Bonuses/Bonus for example.  You can only have one action done for each of these, so you'll probably need a transformation action that takes the same context as your for-each as input.  Each invocation will have the above mentioned loop-iterator service variable that has the actual Bonus node that was matched, so you could use the INPUT context for any general information in the request and loop-iterator service variable for this specific bonus information to build your specific bonus request document.  You could store your request into a content of its own, and use a loop-count service variable as well so you'd have var://context/BonusRequest[1=n] after this first for-each.  I'd suggest you then do a transformation action that uses the loop-count to then build a url list that would specify a unique input context for each url that you are sending, and specify that all requests must be fullfilled.  That list will be placed into a context variable and used on a result action that follows as the destination url.  This action has an option on the advanced tab to give a unique context name for each destination.  The infocenter has a page that describes this at http://pic.dhe.ibm.com/infocenter/wsdatap/v5r0m0/index.jsp?topic=%2Fcom.ibm.dp.xi.doc%2Fxmlfirewalldevelopersguide.xi50122.htm&path%3D4_3_4_6_8_1. Following that, you should have n BonusResponse contexts that you could use, again with INPUT if required, to build an aggregated request to send to the eventual backend.  If you want to make the result action asynchronous (not a result-async action, but selecting the async property on the result action, you can do other processing after this, and an event sync would stop the processing until that action completed.  For example, you could do another for-each on your redemption nodes.

              As I said, somewhat off the cuff, but hopefully it gets you started in the right direction.

              Regards,

              Steve

              • DataPowerDev
                DataPowerDev
                10 Posts
                ACCEPTED ANSWER

                Re: How to access current context of for-each from "loop action" Action?

                ‏2013-07-19T13:55:03Z  in response to swlinn

                Thank you Mr Steve for your prompt response!.

                It sound little complex not making much progress. No surprise for someone who hasn't utilized for-each action.