5 Replies Latest reply: Feb 27, 2014 2:24 PM by 918135 RSS

    Dynamic Invocation on REST Services

    918135

      Hi,

       

      I am new to OAG. Couldnt find documentation on below questions. Can you please provide inputs.

       

      Question's:

       

      1. Would it be possible to use single policy to invoke few external REST services. We want to externalize the URL in "Routing-->Connect to URL" activity.

      2. For some cases we would like to Set target URL based on the Request Relative URL. Is this possible?

       

      Thanks

      Ramana.

        • 1. Re: Dynamic Invocation on REST Services
          StefanOEG

          Hi Ramana,

           

          1. Yes, you just serialize several Connect to URL + Connect filters and they will execute in order. Just be aware that any response will be stored in the attribute body.content and that will be overwritten by every Connect to URL filter so you will need to store the responses to a different attribute if you are running many of them in sequence.

           

          2. You can get the original path by either using the selectors ${http.request.uri} or ${http.request.path}

          Difference is that URI will have URL parameters included and Path will have them stripped off.

           

          From the docs:

          Name: http.request.uri

          Description: Contains the URI on which the HTTP request is received by the API

          Server (for example, /test?location=dublin).

           

          Name http.request.path

          Description Contains the path on which the HTTP request from the client is received

          by the API Server (for example, /test).

           

          Cheers,

          Stefan

          • 2. Re: Dynamic Invocation on REST Services
            918135

            Thanks Stefan.

             

            -Ramana.

            • 3. Re: Dynamic Invocation on REST Services
              918135

              Hi Stefan,

               

              One other question.

               

              I would like to extract value from the variable ${http.request.path}

               

              Ex: If ${http.request.path} = /test/ramana/details, I would like to define variable say "customer" and assign "ramana" to customer.

               

              Use Case: I want to set this variable "customer" to "Service Context".

               

              I tried to use "Extract Path Parameters", ad explained in Extract Path Parameters

               

              But I am unable to add success path from Extract Path Parameters to Set Service Context .

               

              Policy Path:

               

              Extract Path Parameters --> Set Service Context --> Connect to URL.

               

              Can you please help.

               

              Thanks

              Ramana.

              • 4. Re: Dynamic Invocation on REST Services
                StefanOEG

                Hi Ramana,

                 

                I just did a very quick test with Extract Path Parameters -> Set Service Context -> Set message (to send back one path parameter) -> Reflect message and had no issues doing this.

                 

                What version are you running of OAG? I have seen an issue that some filters gets "hidden" in a policy container which can get that behaviour(Usually after been adding/deleting a lot of filters over time). Try recreate your policy fresh!

                 

                Cheers,

                Stefan

                • 5. Re: Dynamic Invocation on REST Services
                  918135

                  Thanks Stefan. Now it works. You saved my time.

                   

                  -Ramana.