Solved

Returning modified JSON in same call


Badge

Hi, I am looking at returning modified JSON requests from a Government geocoding service - the call would be issued from a Geocortex application.

Geocortex issues the call (with an address or XY parameter) - the workspace issues the request, receives the JSON response, does a match on an external ESRI geodatabase to draw in an extra key:value pair, appends this to the response and returns the modified JSON to Geocortex.

This is all working well, apart from the last bit - which I haven't got my head around yet. I could, but would prefer not to, write a JSON file out for Geocortex to read, although this would add more time.

Any help would be much appreciated.

Further information:

Currently takes around 7+ seconds to run (700k records in the geodatabase, but I am using a 5m radius spatial filter) - a C# routine (using an address CSV) takes less than a second, so any performance ideas would be welcome.

This would eventually be hosted on FME Server.

Many thanks,

Mark

icon

Best answer by markdmclean 6 June 2019, 00:30

View original

2 replies

Badge

Update: Now have the process working for single matches - Feature Reader does the match on the GDB, JSONUpdater inserts the extra key:value pair into the response and a JSONWriter spits out the desired results.

By itself, writing the JSON to a file is sub-optimal, but the secret is to upload the workspace to FME Server and select the data streaming option - you can then intercept the modified response mid-flight.

Currently working on multiple matches (worst-case scenario has 17 matches for the one address).

Badge

Due to project timeframes, I reverted to embedding most of the functionality in the PythonCaller - which was, in the end, deceptively simple:

  1. load the JSON from _response_body into a python List
  2. extract the search string(s) from the List
  3. query the SDE for the matching field
  4. add the results to the List
  5. dump the List to JSON
  6. finally, expose the JSON in the PythonCaller

It was then a matter of adding a JSON Writer (with any old output location - as we are interested only in the data streaming functionality when it hits FME Server).

 

Reply