Select to view content in your preferred language

GPResultImageLayer - No Image

3484
10
02-02-2011 07:20 AM
IgressT
Emerging Contributor
Hi,
I created a simple python script that creates a buffer. I have also created a result map service. However, no result image shows up. I am not sure if it is due to my python script or silverlight code.
Here is my python code:

import arcpy, sys, os, string
workspaceName = r"C:\...\databaseconn.sde"
arcpy.env.workspace = workspaceName
arcpy.gp.overwriteOutput=1

result=arcpy.Buffer_analysis("polygon", "polygon_buffer", "5 MILES", "", "", "", "")

featset = result.getOutput(0)
arcpy.SetParameter(0,featset)


(The polygon feature class has over 10000 polygons).

I add this python script to a toolbox and run the script once and then add the python script to the mxd document (drag and drop). I save the mxd document and from ArcCatalog I publish the service. In the ArcCatalog I can see two services are created. 1. A geoprocessing service and  2. A Map service.

From my silverlight code I call the rest url and execute the task. The task executes successfully:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string url = "http://mymachine/ArcGIS/rest/services/GPResultService/GPServer/Buffer";

            Geoprocessor geoprocessorTask = new Geoprocessor(url);
            geoprocessorTask.UpdateDelay = 1000;
            geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
            geoprocessorTask.Failed += geoprocessorTask_Failed;

            List<GPParameter> parameters = new List<GPParameter>();
            geoprocessorTask.SubmitJobAsync(parameters);
        }

private void GeoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e)
        {
            Geoprocessor geoprocessorTask = sender as Geoprocessor;

            geoprocessorTask.GetResultDataCompleted += (s1, ev1) =>
            {
                if (ev1.Parameter is GPFeatureRecordSetLayer)
                {
                    GPFeatureRecordSetLayer gpLayer = ev1.Parameter as GPFeatureRecordSetLayer;
                    if (gpLayer.FeatureSet.Features.Count == 0)
                    {
                        geoprocessorTask.GetResultImageLayerCompleted += (s2, ev2) =>
                        {
                            GPResultImageLayer gpImageLayer = ev2.GPResultImageLayer;
                            gpImageLayer.ID = "BufferLayer";
                            gpImageLayer.Opacity = 0.7;

                            myMap.Layers.Add(gpImageLayer);
                        };
                        
                        geoprocessorTask.GetResultImageLayerAsync(e.JobInfo.JobId,"featset");
                        return;
                    }
                }
            };

            geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "featset");
        }



geoprocessorTask.GetResultImageLayerCompleted event is raised and the gpImageLayer is added to the map. However there is nothing in the layer I mean I cannot see any image on the map .

Can anyone let me know what is wrong

Thanks
0 Kudos
10 Replies
JMcNeil
Deactivated User
You see the layer added to the MXD when you run the tool right? 

If yes then what projection is your output in?  Is it the same as your Map App?  Check your endpoint and see what the GPFeatureRecordSetLayer spatial ref is.  It will create a graphic based on this projection and it should match the projection of your application.  

Are you using Fiddler to follow the sent inputs, the processing, and the sent outputs.  Fiddle will tell what your server is telling your machine and should help.

J
0 Kudos
IgressT
Emerging Contributor
You see the layer added to the MXD when you run the tool right? 

If yes then what projection is your output in?  Is it the same as your Map App?  Check your endpoint and see what the GPFeatureRecordSetLayer spatial ref is.  It will create a graphic based on this projection and it should match the projection of your application.  

Are you using Fiddler to follow the sent inputs, the processing, and the sent outputs.  Fiddle will tell what your server is telling your machine and should help.

J


Yes I see the layer added to the MXD when I run the tool. The projection of output is same as Map App.
I an trying to to use fiddler (which I don't how to).
0 Kudos
JMcNeil
Deactivated User
Launch you web application and launch Fiddler.  Get to point in your web application right before you fire the GP Query.  At this point I usually clear Fiddler (Clicked the Remove Tab and then Click ALL); this is not necessary it just cleans up the previous web traffic.  All your new web traffic will add to the left window pane name "Web Session" the new stuff adds to the bottom of the list.  You can explore each new session/request by click on it (In the Web Session window panel (left side), then make sure your "Inspector Tab"  is click/surpressed and then click on Web Forms tab (within the inspector area) Web forms will make it easy reading for what your computer is sending to the server. Focus on the query string.  The first one sent after excuting the GP should spell out the GP inputs.  Then watch your session (on the left until it completes) Click on the last one or the last few until you find the one you are looking for....OH YA click "Text View" tab in the bottom/middle right panel.  This will make it easy to read what the server is sending you and what is going on...here is where you should see your outputs sent back to your machine. 

Hope that helps.
J
0 Kudos
IgressT
Emerging Contributor
Launch you web application and launch Fiddler.  Get to point in your web application right before you fire the GP Query.  At this point I usually clear Fiddler (Clicked the Remove Tab and then Click ALL); this is not necessary it just cleans up the previous web traffic.  All your new web traffic will add to the left window pane name "Web Session" the new stuff adds to the bottom of the list.  You can explore each new session/request by click on it (In the Web Session window panel (left side), then make sure your "Inspector Tab"  is click/surpressed and then click on Web Forms tab (within the inspector area) Web forms will make it easy reading for what your computer is sending to the server. Focus on the query string.  The first one sent after excuting the GP should spell out the GP inputs.  Then watch your session (on the left until it completes) Click on the last one or the last few until you find the one you are looking for....OH YA click "Text View" tab in the bottom/middle right panel.  This will make it easy to read what the server is sending you and what is going on...here is where you should see your outputs sent back to your machine. 

Hope that helps.
J


Thanks for the brief tutorial... I was able to use the fiddler and as you suggested I was able to monitor the inputs and outputs and it seems like the "Return Map Service" is not executing.
I ran the ESRI sample located at

http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ClipFeatures

and was able to see with fiddler that it executes the GP task and returns an Image.
However, my GP task it executes successfully and no image is returned which tells me the "Retrun Map Service" is not returning anything.
Any clues?

Thanks
0 Kudos
JenniferNery
Esri Regular Contributor
Have you tried submitting job to your GPServer from your web browser? http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/USA_Data_ClipTools/GPServer/ClipCounties/...

Since you are already using Fiddler, you can run it with your application to get the input values (Kindly see attached) and then use the same input in your web browser, check to see if you still do not get anything back.
0 Kudos
IgressT
Emerging Contributor
Have you tried submitting job to your GPServer from your web browser? http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/USA_Data_ClipTools/GPServer/ClipCounties/...

Since you are already using Fiddler, you can run it with your application to get the input values (Kindly see attached) and then use the same input in your web browser, check to see if you still do not get anything back.


Hi,
Thanks for the reply.
From my silverlight app when I run the code (see at the top of the post) and when the task executes the fiddler shows the following output (see image MyGPTask.png)




As you suggested I submitted the job from the browser and when I click the output I dont see the image but see the following (see image GPBrowser.png)
0 Kudos
JenniferNery
Esri Regular Contributor
That error "exceeded record transfer limit" may be the reason why you are not getting features back. You can look at this help doc http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000400000009000000.htm. It might be the MaximumRecords number you need to adjust.
0 Kudos
IgressT
Emerging Contributor
That error "exceeded record transfer limit" may be the reason why you are not getting features back. You can look at this help doc http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000400000009000000.htm. It might be the MaximumRecords number you need to adjust.


Well my problem is I am not able to return an image using Result Map Service associated with the GP task. Any help regarding that would be great.
0 Kudos
JMcNeil
Deactivated User
Go to your gp service under manager and edit it.

First go to the Parameters tab and bump up your - Maximum Number of Records Returned by Server:
GO CRAZY and set it to something like 50000

Then Go to the pooling tab. and GO CRAZY on
The maximum time a client can use a service:    
The maximum time a client will wait to get a service: 
The maximum time an idle instance can be kept running: 

Give them like a
60000 seconds
6000 seconds
80000 seconds

Don't tell ESRI I said this because I think it might affect performance :rolleyes: when running this GP Service but for now just see if works.
0 Kudos