RE: debugging HTTP requests on Android here's a blog post that may help: http://www.andygup.net/?p=695 -Andy
Do you have any messages in the ArcGIS Server log?Here is a similar post with information that might help: http://forums.arcgis.com/threads/27763-Problem-with-Geoprocessing-Service-Andy
In addition to Mark's code snippet, here's some additional code taken from a Clip and Ship demo that shows another pattern for coding against an asynchronous GP service. The full sample code will be included with the v3 release of our SDK later this year. Or, if you want to see the full app sooner then ping me: agup at esri dot com.strmv.setParamName("Layers_to_Clip"); strmv.setValues(arrayList); final ArrayList<GPParameter> paramlist = new ArrayList<GPParameter>(); paramlist.add(strmv); paramlist.add(areaofinterest); paramlist.add(featureformat); handler = new Handler(); submitJobandPolling(gp, paramlist); /** * Method submitJobandPolling. * @param gp Geoprocessor * @param params List<GPParameter> */ void submitJobandPolling(final Geoprocessor gp, List<GPParameter> params) { try { GPJobResource gpjr1 = gp.submitJob(params); JobStatus jobstatus = gpjr1.getJobStatus(); final String jobid = gpjr1.getJobID(); Log.d("Test", "jobid " + jobid); Log.d("Test", "jobstatus " + jobstatus); // if (!jobstatus.equals("esriJobSucceeded")) { if (jobstatus != JobStatus.succeeded) { handler.postDelayed(new Runnable() { @Override public void run() { try { GPJobResource gpjr2 = gp.checkJobStatus(jobid); GPMessage[] messages = gpjr2.getMessages(); if ( messages!= null && messages.length > 0) { for (int i = 0; i < messages.length; i++) { Log.d("Test", "Message: " + messages.getDescription()); } } Log.d("Test", "Polling thread is: " + Thread.currentThread().getName()); JobStatus status = gpjr2.getJobStatus(); boolean jobcomplete = false; if (status == JobStatus.canceled || status == JobStatus.deleted || status == JobStatus.failed || status == JobStatus.succeeded || status == JobStatus.timedOut) { jobcomplete = true; } if (jobcomplete) { if (status == JobStatus.succeeded) { GPDataFile outputZipfile = (GPDataFile) gp .getResultData(jobid, "Output_Zip_File"); Log.d("Test", "zip file is " + outputZipfile.getUrl().toURI() .toString()); }else { Log.d("Test", "GP failed"); } } else { handler.postDelayed(this, 5000); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, 4000); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
strmv.setParamName("Layers_to_Clip"); strmv.setValues(arrayList); final ArrayList<GPParameter> paramlist = new ArrayList<GPParameter>(); paramlist.add(strmv); paramlist.add(areaofinterest); paramlist.add(featureformat); handler = new Handler(); submitJobandPolling(gp, paramlist);
/** * Method submitJobandPolling. * @param gp Geoprocessor * @param params List<GPParameter> */ void submitJobandPolling(final Geoprocessor gp, List<GPParameter> params) { try { GPJobResource gpjr1 = gp.submitJob(params); JobStatus jobstatus = gpjr1.getJobStatus(); final String jobid = gpjr1.getJobID(); Log.d("Test", "jobid " + jobid); Log.d("Test", "jobstatus " + jobstatus); // if (!jobstatus.equals("esriJobSucceeded")) { if (jobstatus != JobStatus.succeeded) { handler.postDelayed(new Runnable() { @Override public void run() { try { GPJobResource gpjr2 = gp.checkJobStatus(jobid); GPMessage[] messages = gpjr2.getMessages(); if ( messages!= null && messages.length > 0) { for (int i = 0; i < messages.length; i++) { Log.d("Test", "Message: " + messages.getDescription()); } } Log.d("Test", "Polling thread is: " + Thread.currentThread().getName()); JobStatus status = gpjr2.getJobStatus(); boolean jobcomplete = false; if (status == JobStatus.canceled || status == JobStatus.deleted || status == JobStatus.failed || status == JobStatus.succeeded || status == JobStatus.timedOut) { jobcomplete = true; } if (jobcomplete) { if (status == JobStatus.succeeded) { GPDataFile outputZipfile = (GPDataFile) gp .getResultData(jobid, "Output_Zip_File"); Log.d("Test", "zip file is " + outputZipfile.getUrl().toURI() .toString()); }else { Log.d("Test", "GP failed"); } } else { handler.postDelayed(this, 5000); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, 4000); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@lcatania You may have already done this, did you compare the parameters set in your code with the parameters documented in your Geoprocessing Service REST endpoint?As a second suggestion, do you have another working sample that uses the same service that you can compare the HTTP request against? -Andy
I found it very difficult to troubleshoot GP parameter issues until I pointed my device to a Fiddler proxy running on my PC. Once I was able to spy on the JSON requests going over the wire, I was able to copy/paste those parameters into a web browser at the GP service REST endpoint. The problems quickly became apparent...
Are you specifically wanting to use the Viewshed service? If so, it does not support asynchronous execution. Before you can use the Geoprocessing task you have to know whether the task is asynchronous or synchronous. This is described in the ArcGIS Services Directory.
gpJobID = gp.submitJob(params).getJobID(); // If no response in 60 seconds, cancel out gpTimeout = new Timer(); gpTimeout.schedule(new TimerTask() { @Override public void run() { uiHandler.sendEmptyMessage(CANCEL_LOADING_WINDOW); } }, 60000); // Check periodically for results checkGPResults = new Timer(); checkGPResults.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { GPJobResource gpJR = gp.checkJobStatus(gpJobID); if ( gpJR.getJobStatus() == JobStatus.succeeded ) { uiHandler.sendEmptyMessage(CLOSE_LOADING_WINDOW); checkGPResults.cancel(); lyrOutputResults.removeAll(); GPParameter result = gp.getResultData( gpJobID, "SewerMainsTraced" ); GPFeatureRecordSetLayer resultFeats = (GPFeatureRecordSetLayer) result; for (Graphic feature : resultFeats.getGraphics()) { Geometry geom = feature.getGeometry(); final Graphic g = new Graphic(geom, new SimpleLineSymbol(Color.CYAN, 2)); lyrOutputResults.addGraphic(g); } } else if ( gpJR.getJobStatus() == JobStatus.failed ) { uiHandler.sendEmptyMessage(CLOSE_LOADING_WINDOW); checkGPResults.cancel(); showToast( "Error in tracing: " + gpJR.getMessages()[ gpJR.getMessages().length-1 ].toString(), Toast.LENGTH_LONG ); } } catch (final Exception exc) { Log.e(TAG, exc.getMessage()); showToast("Error in tracing: " + exc.getMessage(), Toast.LENGTH_LONG); } } }, 2000, 2000);
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.