Question

Has anyone created a for loop that passes key values from the loop to a web service?

  • 17 October 2018
  • 5 replies
  • 0 views

Badge

I need to create an FME workspace where I query the applicant id's in a table and then loop thru those passing each to a web service call. The return value will then be put into a table with the id passed out to the web service.


5 replies

Badge

Hi @tgolden

If I've understood the question properly, what you're looking for is the default behaviour of the HTTPCaller transformer - have a look at the documentation. It makes the call for each feature which enters it, so you can use your applicant ID's as a parameter. Equally each response will be attached to the feature, so you can use this to do whatever you need thereafter.

Sorry if I've misunderstood.

Badge

I guess I am confused on how I can loop thru the id's from a select statement and then pass those to the HTTPcaller. The HTTPcaller is straightforward enough. Its just that I don't know how to use my SQLexecutor results and individually pass them on to the HTTPcaller. Do you know of any example I could look at?

Badge

I guess I am confused on how I can loop thru the id's from a select statement and then pass those to the HTTPcaller. The HTTPcaller is straightforward enough. Its just that I don't know how to use my SQLexecutor results and individually pass them on to the HTTPcaller. Do you know of any example I could look at?

Hi @tgolden... I'm afraid I'm a little between jobs at the moment so without setting up some data environments I don't have anthing I can easily knock up an example from, sorry.

 

 

But... try adding your SQLExecutor, then as a proof of concept add a sampler inline to select a smaller number of features (or add first n rows to your SQL statement), then connect that to the HTTPCaller with the relevant parameters for your web service. Then connect an Inspector to the output port and see what the results are... you should see that each record in your SQL query results in a call to the web service, which is hopefully what you're looking for. If all good, remove the sample and you should be good to go...

 

Badge

I guess I am confused on how I can loop thru the id's from a select statement and then pass those to the HTTPcaller. The HTTPcaller is straightforward enough. Its just that I don't know how to use my SQLexecutor results and individually pass them on to the HTTPcaller. Do you know of any example I could look at?

I am new to many of these transformers. I have a simple sqlexecutor. returns one id. I pass that id into an HTTP caller to invoke the web service with that parameter or the applicant id then finally the inspector.

 

 

What type of transformer do you need to have before the sql executor to run the sqlexecutor transformer? Basic question but something I cant seem to figure out.

 

 

Badge
I am new to many of these transformers. I have a simple sqlexecutor. returns one id. I pass that id into an HTTP caller to invoke the web service with that parameter or the applicant id then finally the inspector.

 

 

What type of transformer do you need to have before the sql executor to run the sqlexecutor transformer? Basic question but something I cant seem to figure out.

 

 

try a 'creator' ahead of the SQLExecutor.

 

 

Do you have the 'Help' window switched on in FME? If not, then switch it on through the 'view -> windows' menu. Then, if you click on a transformer on the canvass, you'll see dynamic help documentation for the transformer - this is really useful if you don't know what each one does, and lends itself to trial and error!

 

 

So for your workflow, at the moment you should be looking at a Creator connected to a SQLExecutor (with your select statement) connected to HTTPCaller.

 

 

If it works for the one ID, change your SQLExecutor statement to return all of the IDs you want to loop through, not just the one. You should then find HTTPCaller makes the call for each ID in the table.

 

 

Reply