Not able to call Dynamic Endpoints/URLs on the basis of Message Mediation polices in WSO2 API Manager

后端 未结 1 1270
生来不讨喜
生来不讨喜 2021-01-28 00:50

I\'m using APIM-3.1.0 and I need to Redirect APIs’ based upon header or request parameter. I have tried for request parameter but unable to call different API\'s. I have used be

1条回答
  •  野的像风
    2021-01-28 01:38

    Here, you can pass value in header with some variable name and define the same in mediation policies.

    The below Code calls different endpoints on the basis of variable "check" is present or not, if it is present in header with any value,the endpoint_B will get called, if value of check is not present or check is not present in header, then it will call endpoint_C.

    
    
    
    
    
        
        

    There is one more way to do the same thing, you can use Switch case in XML,as shown below and configure multiple endpoints. Here, if you pass the value of check as 'B' in header, endpoint_B will called, else if you pass value of 'check' as 'C' in header, then endpoint_C will get called, and if you pass any other value than 'B' or 'C' or not pass any value or even not pass check in header than default endpoint here endpoint_A will get called.

    
    
    
        
           
            
            

    There is one more way to use switch if your endpoint are running on same host and port by using property="rest_url_postfix" as shown in below code. Here,output will be same as above but some changes that you need to make are for the above code you need to select dynamic endpoint in Endpoints tab in WSO2-APIM publisher while for the below code, you select REST Endpoints and select value of endpoint as http://:// . For example, http://localhost:8080/Test/

    
    
    
    
        
           
            
        
        
            
        
        
            
        
    
    
    

    For anymore information regarding sample mediation sequences refer following links:

    • https://docs.wso2.com/display/APICloud/Sample+Mediation+Sequences
    • https://docs.wso2.com/display/ESB480/HTTP+Transport+Properties

    Hope. This resolves your Query.

    0 讨论(0)
提交回复
热议问题