Best practices with API in WSO2 ESB - wso2

I have an API exposed in WSO2 ESB. In these API there are many resources, and each one of them have oauthservice mediator, dbreport mediator and diferent endpoints for a same API context.
What is the best way to define these resources without repeating the mediators in each resource in WSO2 ESB API?
Thanks in advance.

Include the OAuthMediator and DBReport Mediator inside sequences (sequence for each mediator) and call it within the API definition. You can also create an endpoint key in the registry for the API endpoint and refer it in the API directly as shown below.
<send>
<endpoint key="gov:endpoints/StockQuoteEP.xml"/>
</send>

Related

WSO2 API Manager with ESB

In API Manager, I pass APIs in API Manager with respective services, also after reading documentacion of API Manager version 3.0.0 (https://apim.docs.wso2.com/en/latest/GettingStarted/overview/), I know in Publisher there exists a ESB, also in my case I work with this cases I think is part of ESB:
WSO2 OAuth Mediator(JAR).
File JSON by WSO2 OAuth Mediator, with endpoints referents to API's I'm cosuming.
In publisher page I add Custom Policies in request or response.
But existing WSO2 Enterprise Integrator (EI) version 6.6.0, this component have a ESB.
My questions are:
In my case, really I work with ESB?
How to integrate API Manager with EI?
WSO2 API Manager gateway is built on top of Synapse engine which is the same engine used in WSO2 EI (ESB). Using API Manager you can do simple mediation. But if you want to do any complex mediation, then you should use EI (ESB) along with API Manager.

How to create policy for wso2 identity server Entitlement

I have using Wso2 indendity server 5.7.
i have seen some document for wso2.
link:
https://docs.wso2.com/display/IS570/Entitlement+with+APIs#EntitlementwithAPIs-addPolicy()
my problem how to use this things in postman.
i have seen some document in rest api but in rest api documentation create policy rest api not available.
Rest Api Document:
https://docs.wso2.com/display/IS570/Entitlement+with+REST+APIs
The API documentation you pointed was the SOAP APIs. There is no rest API for creating XACML policy in WSO2 IS. If your requirement is to use postman to publish the policies, you can refer to this. It explains how to send the SOAP request from postman

How to using client_ip and request_uri in XACML policy in WSO2 IS

We are using WSO2 IS as the Identity Bus for our solutions. We make REST API in WSO2 ESB to implement our Integration and use OAuth mediator in that to securing our API.
in WSO2 IS we create a service provider as sp1 and apply XACML policy to that. I want to create XACML policy to permit incoming requests just when client_ip is xxx.xxx.xxx.xxx and request URI is http://wso2ESB.uri/sampleApi/app and method is GET.
please help me to make this XACML policy in WSO2 IS.
Currently WSO2 Identity Server support only scope based XACML policy evaluation for oauth2/oidc service providers, where there is no out of the box capability to evaluate policy against client_ip, request URI, HTTP method. One way to handle this situation is irrespective of oauth mediator you can write custom class mediator to intercept the request (PEP) and invoke EntitlementService to evaluate request against XACML PDP in Identity Server. Inside custom class mediator you can write necessary logic to extract necessary information for XACML request client_ip, request URI, HTTP method ...etc
[1] https://docs.wso2.com/display/IS570/Validating+the+Scope+of+OAuth+Access+Tokens+using+XACML+Policies

How to configure multiple address endpoints to a single endpoint

Am working with wso2esb 4.7.0 and wso2dss 3.0.0.
I have diffident number of data services in my DSS
so, when we are creating a proxy service in my ESB, generally will send the payload to the respective address endpoint of the particular data service in the DSS and will execute the proxy
But what i want to do is create an Endpoint in ESB and configure all my DSS Address endpoints in this Endpoint and use this in all my proxy services
some of my Address endpoints in DSS are as shown below
localhost:9764/services/Get_details/
localhost:9764/services/Get_geodetails/
localhost:9764/services/muser_DataService/
how can i create a default endpoint with this Address endpoints in my ESB
You can use a single proxy in ESB and call different DSS endpoints based on the message contents. Please go through the mediators under Filter category.
For your scenario, you may use the Switch Mediator. From that, you can check for different conditions and send to appropriate endpoint.
For eg: please refer Content-Based Router Pattern
You may use a mediator like Payload Factory to transform message depending on the target endpoint.
I hope this helps.

Can WSO2 API Manager be integrated with MULE ESB?

We are already using mule ESB in our infrastructure. Can API manager of WSO2 use mule ESB as API gateway instead of WSO2 ESB. If YEs, Can somebody please help me with Steps.
I have doubt how to achieve throttling and Rate limiting features of API manager in mule ESB if replaced and how seamless integration is?
This is possible due to the pluggable architecture of WSO2 API Manager, but this is not straight forward. The Gateway component of the API Manager handles Token Validation, Throttling, Caching and Mediation. Of these features Token Validation is configurable out of the box with any external Token Validating component since it uses Web service calls since it has a Web Service interface. The other 3 features will require customization at code level in order to function with Mule ESB. Therefore this is not the most recommended approach.
WSO2 API Manager can be used without an external ESB instance out of the box. So that would be the best way to use it.