Topic
5 replies Latest Post - ‏2012-12-13T09:50:20Z by HermannSW
SystemAdmin
SystemAdmin
6772 Posts
ACCEPTED ANSWER

Pinned topic Response in request rule

‏2012-12-11T18:33:56Z |
Is there a way to send a response from within a request rule?

The scenario is: get request from client to an mpgw, validate and transform the request. At this point I want to send a response back to the client so that they can close the transaction. After sending the response to the client, I want to continue to process to the request rule and route to the intended back end. The back end then sends a response, which in turn needs to be sent as a request to a new back end.

I’ve got the whole flow working (side call to the first back end and then continue and send response as a request).

What are my options for sending a response back to the client during processing of the request?
Updated on 2012-12-13T09:50:20Z at 2012-12-13T09:50:20Z by HermannSW
  • HermannSW
    HermannSW
    4379 Posts
    ACCEPTED ANSWER

    Re: Response in request rule

    ‏2012-12-11T20:03:55Z  in response to SystemAdmin
    >
    > I’ve got the whole flow working (side call to the first back end and then continue and send response as a request).
    >
    If you would mark the side call "asynchronous" it should behave as you want.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    • SystemAdmin
      SystemAdmin
      6772 Posts
      ACCEPTED ANSWER

      Re: Response in request rule

      ‏2012-12-12T09:43:16Z  in response to HermannSW
      I’m not that familiar with the asynchronous mode, With the request rule flow in my mpgw being

      match all > validate > transform > result (side call) > transform > result

      When making the first results action (side call) asynchronous, would this not make the request rule continue processing (second transform) even if we don't have a response back from the side call? Or would this call my response rule?

      I want to send a response before making the side call (after the first transform), and then continue with the request.
      • HermannSW
        HermannSW
        4379 Posts
        ACCEPTED ANSWER

        Re: Response in request rule

        ‏2012-12-12T16:52:01Z  in response to SystemAdmin
        >
        > match all > validate > transform > result (side call) > transform > result
        >
        > When making the first results action (side call) asynchronous, would this not make the request rule continue processing (second transform) even if we don't have a response back from the side call?
        >
        yes, does the 2nd transform depend on the result of the sidecall?
        If so, you could encapsulate "result (side call) > transform" into a callable rule and mark the "call rule" action asynchronous.

        > Or would this call my response rule?
        >
        Why do you want to call a response rule?
        You could set "var://service/mpgw/skip-backside" either in Set Variable action or a stylesheet, then the results action of request rule resturns respoinse to client.
        Otherwise you would need to go against a (dummy) backend just to execute the response rule (you can do so, of course).

        > I want to send a response before making the side call (after the first transform), and then continue with the request.
        >
        Why? If it is called asynchronously it does not make a difference.

        So this might be what you want:
        match all > validate > call rule(asynchronously) > set-variable(var://service/mpgw/skip-backside,1) > result
        callable rule: match all > result (side call) > transform

        You did not tell for what reason the 2nd transform should do transform the result of the side call and for whom/what.

         
        Hermann<myXsltBlog/> <myXsltTweets/>
        • SystemAdmin
          SystemAdmin
          6772 Posts
          ACCEPTED ANSWER

          Re: Response in request rule

          ‏2012-12-12T17:55:55Z  in response to HermannSW
          Thanks for the reply Hermann.

          The 2nd transform does depend on the output of the side call (the output from the side call is the input to the 2nd transformation)

          The initial request from the client is a synchronous call, hence a response is required. The side call can take up to 2 mins to send a response, due to the long duration, a response is sent to the client (along with the datapower transaction id is for auditing purposes) to indicate that the request has successfully been received.

          The response from the side call needs to be processed as a request for a new web service call, by transforming (2nd transformation).

          The idea behind the initial logic I created was

          match all > validate > transform > result (side call) > transform > result

          Where the destination url for the second result is set, once a response is received form the side call.

          So, as you mentioned my new flow could be:

          match all > validate > transform >call rule(asynchronously) > set-variable(var://service/mpgw/skip-backside,1) > result
          (Which will call the callable rule, finish processing and send a response to the initial client)

          callable rule: match all > result (side call) > transform > results
          (Which will make the side call, wait for a response, transform and send as a new web service request?)

          That would work, exactly as intended.
          • HermannSW
            HermannSW
            4379 Posts
            ACCEPTED ANSWER

            Re: Response in request rule

            ‏2012-12-13T09:50:20Z  in response to SystemAdmin
            > ...
            > callable rule: match all > result (side call) > transform > results
            > (Which will make the side call, wait for a response, transform and send as a new web service request?)
            > ...

            Yes, the transform does the new web service request.
            Be aware that there is a "results" action in the called rule.
            But since the calling rule has already ended the result will go nowhere.

             
            Hermann<myXsltBlog/> <myXsltTweets/>