1

How i can get result of this query in Arcgis Javascript Api?? or how i should publish the its services to work and send for me result?? i run this query and it works in ArcMap but when i publish it , i receive this error

'"Invalid return value: in_memory/Buffers2"'

as messages on Arcgis Javascript Api..

import arcpy
arcpy.env.workspace = "c:/ArcpyBook/data/TravisCounty"
streams = "Streams.shp"
distance = "2640 Feet"
bahman='in_memory/Buffers2'
arcpy.Buffer_analysis(streams,bahman,distance,'FULL','ROUND','ALL')
arcpy.SetParameterAsText(0,bahman)

tanks to your answers i already do this test query and it work fine for me

import arcpy
Input=arcpy.GetParameterAsText(0)
Input=Input+':: http://gis.stackexchange.com' 
arcpy.AddMessage('Input is :'+Input)
arcpy.SetParameterAsText(1,Input)

next i add script in ArcMap then run this script and publish the result and call services in Arcgis javascript api enter image description here

indeed i want to do Geometric network analyze in my app that show results with Arcgis Javascript Api

in esri tutorials i find to do it with ModdelBuilder next run it and then publish result. in that tutorial set defalt parameter to

in_memory\{68225AF2-773D-4B79-BBD3-EE72DE8999E3}

enter image description here

i know 'in_memory' refrenced to inmemory workspace but do not undrestand this value '{68225AF2-773D-4B79-BBD3-EE72DE8999E3}'

is there any way to acomplish this steps only with python?? i want set input and outPut parameters in python script.i do not want set this parameters in ModelBuilder...

  • 1
    How do you have the output in the actual thx defined? Output derived? What sort of parameter, feature class? – KHibma Oct 12 '15 at 12:46
3

The two options I know are to take that data and publish it as a new map/feature service, or the better option (unless you want a bunch of map/feature services being created), is to pass back a FeatureSet and let your JS handle it accordingly.

When you run your geoprocessing service, it is sending information back to your server. The server will process the information according to the tool/script provided in your GP service. Once that is done, it will communicate back to the web client the result. Basically, when you make the call to your GP service, you pass in a callback function that will handle the return result.

This info site has an example. A brief bit of the code goes like:

gp.submitJob(params, completeCallback, statusCallback);

What is happening above is: params are the parameters you're passing to your GP service. completeCallback is the function that is called when n the jobStatus is equal to STATUS_SUCCEEDED. statusCallback is an update function used to pass messages from the server back to you. When it is done, you get back a FeatureSet to handle whichever way you desire. In the site's example, they draw graphics onto the map.

function displayResult(result, messages) {
  var simpleLineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
          new dojo.Color([255,255,0]), 1);
  var features = result.value.features;
  for (var f=0, fl=features.length; f<fl; f++) {
    var feature = features[f];
    feature.setSymbol(simpleLineSymbol);
    map.graphics.add(feature);
  }
}
  • You can certainly use inmemory output with a gp service. The only time your final output cannot be inmemory is if you're using a result map service. – KHibma Oct 12 '15 at 12:45
  • Modified for a little better clarification. I meant back to client browser, not within the GP service itself. – Branco Oct 12 '15 at 12:48
  • JS or rich ArcMap client, it doesn't matter if the features were written to inmem or as a shape file. The service sends features back to the client and the client draws them. – KHibma Oct 12 '15 at 12:50
  • I haven't done it that way before. Do you have a sample you could add as an answer and help the poster? – Branco Oct 12 '15 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.