Layer7 API Management

 View Only
  • 1.  Converting URI for REST service.

    Posted Oct 30, 2018 05:28 AM


    I'm configuring an API gateway for accepting REST request.

    The backend REST URL is as below.{bhno}/{cseq}/{upno}/{xtype}

    /benefit/reconsigned/fund/single/findInvestoryByCseq is fixed part.

    /{bhno}/{cseq}/{upno}/{xtype} is dynamic information.


    However, the client hopes to publish this REST service using the following URL to their customers.{bhno}/{cseq}/{upno}/{xtype}

    /fsts/benefit/fund/single/cseq/ is fixed part.

    /{bhno}/{cseq}/{upno}/{xtype} is dynamic information.


    Yes. The /benefit/reconsigned/fund/single/findInvestoryByCseq/ has been changed to /fsts/benefit/fund/single/cseq/.


    I tried to create a web api for listening "*" and route to "*" but failed.


    What should I do to make this web api work?



    Best Regards,

  • 2.  Re: Converting URI for REST service.
    Best Answer

    Broadcom Employee
    Posted Oct 30, 2018 06:43 PM
      |   view attached

    Use regex assertion to replace /fsts/benefit/fund/single/cseq/ as /benefit/reconsigned/fund/single/findInvestoryByCseq/ in ${request.http.uri}, then use  the replaced uri for route via http assertion


    I attached a sample policy, when I call http://<gateway>:8080/fsts/benefit/fund/single/cseq/abc/bymark?pa=v1, the new url${myuri}${request.url.query} will become




    zip   884 B 1 version

  • 3.  Re: Converting URI for REST service.

    Posted Oct 31, 2018 01:23 AM

    Hi Mark,

    Thanks for your fast and correct response. It helps me a lot.

    I'd like to ask another question from this example.


    If I need to set each parameter within URI as a gateway variable,

    /{bhno} = ${bhno}

    /{cseq}     = ${cseq}

    /{upno}     = ${upno}

    /{xtype}     = ${xtype}

    How can I do to fulfill this requirement?


    Best Regards,

  • 4.  Re: Converting URI for REST service.

    Posted Oct 31, 2018 05:23 AM

    Hi Mark,

    I tried the regex assertion all day long and finally, I found a way to retrieve the values from URI.

    The first step is to trim the fixed part of URL.





    The second step is to use the following expression and place the result to a variable.



    The variable will be an array and [1]~[4] will be each value.


    Best Regards,

  • 5.  Re: Converting URI for REST service.

    Broadcom Employee
    Posted Oct 31, 2018 06:29 PM

    Dear Gary,

    I am not sure if I understand your case properly, but I thought you're going to copy the "dynamic part” {bhno}/{cseq}/{upno}/{xtype} from the incoming request url.

    If true, we only need to replace the "fixed part”, my demo policy should keep the "dynamic part” from the original url.


    If the "dynamic part” will be generated locally in policy, assume that you will set following context variables (${bhno}, ${cseq}, ${upno}, ${xtype}),  then we don't need the regex at all, in Route via http assertion, we may just input the url as below,${bhno}/${cseq}/${upno}/${xtype}${request.url.query}




  • 6.  Re: Converting URI for REST service.

    Posted Oct 31, 2018 11:56 PM

    Hi Mark,

    Your sample policy works well and indeed solve my problem.

    About my second question. I'm sorry that I forgot to tell you this is another situation 


    My first question is for a REST to REST service, the second one is REST to SOAP service.

    That's why I need to retrieve each value from the dynamics part. I  need them to generate a SOAP request.

    It's ok. I already solve it.

    Thank you.

  • 7.  Re: Converting URI for REST service.

    Broadcom Employee
    Posted Nov 01, 2018 06:38 PM

    You're welcome