I have implemented an api proxy which calls a websevice. i need to make multiple similar callouts to a webservice. I would like:
How do i implement this in nodejs? or is there better way to do it?
please help
Yes nodejs would be the right way to go. You can use nodejs to make http callouts using frameworks like argo. Here's an example:
var argo = require('argo'); var express = require('express'); var app = express(); var proxy = argo() .target('http://example.com') .build(); app.get('/hello', function(req, res){ res.send('Hello from Express'); }); app.all('*', proxy.run); app.listen(3000);
Adding a nodejs target to an existing proxy is really simple. Once you have this nodejs script, in your TargetEndpoint instead of HTTPTargetConnection element, just refer to the nodejs as a ScriptTarget, like this:
<ScriptTarget> <ResourceURL>node://callout.js</ResourceURL> <Properties/> </ScriptTarget>
The requirement is like this i have implemented a mashup of two apis .
In that one api is called multiple no of time using a javascript and by getting values from first api and adding it in array and making multiple calls in sequence .
I want make these calls in parllel which can be achieved using nodejs.
I want to know where this nodejs has to added.
do i have to create a different target endpoint for it or can it be implemented in existing flow?
You've just given me the info I was searching for. Thanks for the info, you made it easy to understand. Merging files is super easy with AltoMerge. Try it on your own here http://goo.gl/lHMuvo and you'll make sure how it's simple.
It is possible to make async requests with the standard javascript policy. Here's a sample that does that. https://github.com/apigee/api-platform-samples/tree/master/sample-proxies/async-callout
In that sample the values are static. If my values are dynamic like i am having webservice that will give list of cities with zipcodes and for these each cities with zip codes i need get weather data for each city. how do i implement it so that i can call them async .
If the number of zip codes is dynamic, it gets more complicated to use javascript callouts. I think node.js might be a simpler way to implement things when you don't know how many callouts you're going to need to make. When you create a node.js proxy in Edge it's not handled the same as adding a javascript extension policy to an existing proxy. The node.js script becomes the "target" for the proxy. You can still apply policies to flows as you would with any other back-end target, but in addition you can use the apigee-access module to get access to flow variables directly from your node.js code.
I would start by building out a sample as described here: http://apigee.com/docs/api-services/content/getting-started-nodejs-apigee-edge
Then look at the apigee-access module: http://apigee.com/docs/api-services/content/using-apigee-access
I've used the async module to do something very similar to what you're describing. https://github.com/caolan/async
I can share code if it would help.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |