Reputation: 15
How to call a rest api from within the mule proxy
Clients -> Mulesoft proxy (I need to call a Rest service A , here to authenticate a client ) -> if authentication passes then call actual REST service B.
Upvotes: 0
Views: 1135
Reputation: 637
This is how you can create a mule app to call a backend service if authenticated properly.
Client -> Mule App A(apply API manager policies) -> if authenticated call service B
Some additional info: Typically, you would have a DMZ or an edge zone where you would deploy your gateway components through which traffic would flow into your enterprise and hit various applications. One such internal application could be Mule app A developed to call your backend REST service B. Now, to protect your developed Mule app API endpoint with security API policies you could use API manager. Once you do this within API manager by selecting all the relevant policies such as client credentials, Oauth jwt validation or rate limit etc, the anypoint platform spins up a Mule app which with all these policies embedded in the app(also known as the proxy app) and will ask you to point to a backend API which would be the Mule app A that you previously developed. You also have to select a runtime to run this Mule proxy app which typically be in your edge runtime environment/zone. Basically, the anypoint platform creates this app for you and does the embeds the required code/policies etc. Now if required you can edit this app as well which I wouldn't recommend.
Clients -> Mule proxy app(Security policies applied) -> Mule app A -> REST service B
Upvotes: 0
Reputation: 25699
An API proxy in Anypoint Platform is implemented as a Mule application to which policies are applied. You have to download the proxy, import it into Anypoint Studio and edit it to add the HTTP request to service A, then continue as before. If the authentication fails with an HTTP response status >= 400 you probably don't need to do anything special, unless you need to customize the HTTP request error status check or customize the response status.
Upvotes: 1