Layer7 API Management

  • 1.  Context variables from service policy not available in Message-Completed global policy fragment

    Posted Oct 11, 2018 05:17 PM

    I'm setting some context variables in my services and then want to reference them in the message-completed global policy fragment but it says 'Unsupported variable'.  This appears to be inconsistent with the documentation:

    Global Policy Fragments - CA API Gateway - 9.2 - CA Technologies Documentation

    "A global policy shares the following with a service policy:

    • request/response messages
    • message context mappings
    • audit/fault settings
    • authentication details
    • built-in context variables (all other variables local to the policy being run)"

    For now I've put the value into the request headers post-routing so I can grab it after, but in case of routing failure I will not have them available.



  • 2.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Broadcom Employee
    Posted Oct 22, 2018 11:59 AM

    What context variable are you attempting to use and what global policy are using?

     

    Sincerely,

     

    Stephen Hughes



  • 3.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Posted Oct 24, 2018 10:53 AM

    In the message-completed global policy fragment I want to reference some context variables that were declared in the service policy.  The weird thing is that some are working and another was not.  in both cases the context variable is being returned from an encapsulated assertion.  In the message-completed I am mapping them into a request header (I know it's after routing) and then reference the request header in the traffic-logger cluster-wide property.



  • 4.  Re: Context variables from service policy not available in Message-Completed global policy fragment
    Best Answer

    Broadcom Employee
    Posted Nov 01, 2018 04:36 AM

    Hi Benjamin,

     

    Did you try and use the "Export Variables from Fragment" assertion in your service? In Global policy you should then be able to reference the variable via ${request.shared.<variable Name>}.

     

    Let me know if that helps.



  • 5.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Posted Nov 13, 2018 07:01 PM

    I'm not calling a fragment in the message-completed policy fragment.  Are you suggesting at the end of the service policy I add an Export Variables from Fragment?



  • 6.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Broadcom Employee
    Posted Nov 14, 2018 03:27 AM

    Yes, that would be my suggestion



  • 7.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Posted Dec 03, 2018 12:16 PM

    I finally got around to trying this, it did not work.



  • 8.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Broadcom Employee
    Posted Dec 03, 2018 12:44 PM

    Hi Benjamin,

     

    Would you be able to provide a sample of your policy to review? If I understand right, this is the setup you have (example data to get the flow)

     

    Service1 - policy

    Encap sets variable ERROR to 10

    Set context variable newError = ${ERROR}

     

    msg-completed:

    audit ${newError}

     

    Here is a sample of how I was testing and got it to work.

     

    The 'OTK Require OAuth 2.0 Token' returns an error variable named ${ERROR.CODE}. If this errors out the return template allows the policy to proceed (not falsify) and then sets the variable ERROR to ERROR.CODE.

     

    The export then exports ${ERROR} from the policy.

     

     

    My message complete policy includes a simple audit using the request.shared as Conny noted.

     

     

    If the return template was excluded the policy would falsify and the variable would not reach the export point.

    Perhaps if we can see a sample of what you are working with  we can help figure this one out.

     

    Regards,

    Joe



  • 9.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Broadcom Employee
    Posted Jan 21, 2019 06:05 PM

    Ben,

     

    Did this address the issue that you had?

     

    Sincerely,

     

    Stephen Hughes

    Broadcom Support



  • 10.  Re: Context variables from service policy not available in Message-Completed global policy fragment

    Posted Jan 22, 2019 10:26 AM

    OH, I missed the .shared, I bet that is what it was.  I'll try that later this week to confirm...