From: http://www.woxihuan.com/46528208/1339982748088020.shtml
ArcGIS GP service question list
1.
Input parameter error
When using the GP service, you need to pay attention to the input and output parameters throughout the process from model creation to service release to service calling. For details about the input and output parameters supported by the GP service, see
Http://help.arcgis.com/zh-cn/arcgisdesktop/10.0/help/index.html#/na/00530000001n000000/
If the type of the input parameter is different from that of the GP service, an error is returned.
If the input or output parameter type is not supported by the GP service, the GP service will not be published successfully.
When we obtain the execution result of the GP service, we need to note that the name of our result must be consistent with the name of the output result of the GP service! For example:
This is the output parameter information of the published GP service:
Here we can know that the output parameter name is:SurfaceoutputWhen requesting services, make sure that the parameter names are consistent.
_ Geoprocessorjobtask. getresultimagelayerasync(E. jobinfo. jobid,"Surfaceoutput");
This code is used to obtain the GP execution result from the server. The result name is:Surfaceoutput,Must be consistent with the output parameters of the GP service.
For exampleSurfaceoutputChangeErrosurfaceoutputThe following error occurs:
So we can also know that when an error occurs, we can check whether the parameters for getting the GP service result are consistent!
Similarly, we also need to maintain the consistency of input parameters. When the input parameters are inconsistent, the following error occurs.
For example, the basic information of the input parameter of the GP service is as follows:
When we call the GP service, we enter parameters of the gpfeaturerecordsetlayer type.
Jobgpparameter. Add(Newgpfeaturerecordsetlayer("Polutionpoints",Featuredata));
Note that here polutionpoints is the name of the GP service input parameter, which must be the same as the parameter name of the GP service. If we change polutionpoints to another name, the following error will occur:
2.
Beyond the boundary.
This is generally because the attribute domain of the selected coordinate system is too small During modeling.
For example, when the input parameter is a vertex element, when we create a vertex element, we need to select the coordinate system of the vertex element (you can also chooseUnknown). When we do not selectUnknownThen, the attribute fields of our elements are fixed (Select unknownTime will be much smaller). For example, if the selected coordinate system is wgs_1984, its attribute domain range is as follows:
When unknown is selected, the attribute fields of the element are as follows:
So we can know that different coordinate systems are selected, so the attribute fields are different.
Therefore, due to the limitations of the XY attribute domain range, when the XY coordinate of the Point parameter we input exceeds the range of the XY attribute field, an error is returned when the GP service is called, as shown below:
The solution is to set the coordinate system of the input vertex elements to unknown.
3.
Synchronous and asynchronous
When we publish the GP service, we will choose whether it is synchronous or asynchronous. Synchronous calling of the GP service is actually done on the client, the results are stored on the client, the asynchronous calling is actually executed on the server side, the results are stored on the server side, and the client is requested on the server side. When the amount of data processed is small and you do not need to wait too long, you can use synchronization. When the amount of data processed is large, you need to wait for a while, then we can select the Asynchronous Method.
Therefore, since the GP service is divided into synchronous and asynchronous services, we need to know which method to adopt when releasing and calling the GP service.
For example, the published GP service is synchronous and can only be called in synchronous mode:
_ Geoprocessorexecutetask. executeasync(ExecuteGpparameter );
Similarly, when the GP service is asynchronous, the following calls:
_ Geoprocessorjobtask. submitjobasync(Jobgpparameter);
However, if we publish a synchronous GP service and call it in asynchronous mode, the following error will occur:
4.
An error occurred while setting the object to an instance of the class.
This error occurs when I asynchronously request the GP service to obtain the execution result of the GP service. The error code is as follows:
The yellow part indicates the error.
The complete code for obtaining the asynchronous call result is as follows:
Void
Geoprocessortask_getresultdatacompleted(Objectsender,Gpparametereventargse)
{
Graphicslayer
Graphiclayer = map. Layers["Countorlayer"]Asgraphicslayer;
Gpfeaturerecordsetlayer
Feature = E. parameterasgpfeaturerecordsetlayer;
Foreach(Graphic
Graphicinfeature. featureset. Features)
{
Graphic. symbol = layoutroot. Resources["Redlinesymbol"]Asesri. ArcGIS. Client. symbols. Symbol;
Graphiclayer. Graphics. Add(Graphic);
}
}
There is no error in this code, but an error is reported when you run the program, saying that the object has not been referenced to the instance of the object, and then on-demand by "Bodhi old King, I found that none of my GP services were successfully executed (fialded). In other words, E. there is no result in parameter, so it is not successful to assign a value to the feature.
Gpfeaturerecordsetlayer
Feature = E. parameterasgpfeaturerecordsetlayer;
Therefore, an error is reported when the features in the feature is traversed later.
When the GP service is successfully executed, the above error is not displayed. debugging shows that multiple features exist in the feature. It indicates the operation is successful.
5.
Remote service notfound Error
Sometimes, when we call the GP service, the following error occurs: remote service notfound, and we find that the GP service is the correct result, but SL cannot be displayed, and the following error is reported:
The reason is that Silverlight itself accesses server resources. You can solve the problem by adding the following code before sending a GP service request;
// It is important to add this code. Otherwise, the remote server not found error may occur.
Httpwebrequest. registerprefix("Http ://",System. net. browser. webrequestcreator. clienthttp);
Jobgpparameter. Add(Newgpfeaturerecordsetlayer("Polutionpoints",Featuredata));
_ Geoprocessorjobtask. submitjobasync(Jobgpparameter);
6.
GP is successfully executed, but the result cannot be displayed on the map.
This problem is actually a model problem. I have encountered it before. I was puzzled at the beginning, because I published a GP service and successfully verified it In ArcMap, the call was successful, but the result cannot be displayed on the current graph. view the jobs folder and find that the result is generated.
Then, the model is re-created, the Environment workspace is re-set, and the Output Folder path is re-set. Then the problem is solved. Of course, it is true that for this reason, this is just my conjecture, but re-modeling can certainly solve this problem.
The above are some of the problems I encountered when using the GP service. I made a small summary again. If there are any imperfections or errors, I hope that we can point out that everyone is learning from each other, make progress together!