AnsweredAssumed Answered

Query ArcGIS server map service layer in C#

Question asked by JZhangGDOT on Jun 22, 2017

Hi, 

I am developing a application using C# and ArcObjects 10.4.1 and need to query ArcGIS Server 10.4.1 map service layer. My service has a lot of layers, I am trying to query some of the layers in the map service. I am thinking to using code something like the following, but never get it to work. Can anyone point me to right direction? I appreaciate any input.

see my current codes below.

Thank you in advance.

 

ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Server);
restLayer = new MapServerRESTLayer();
restLayer.Connect("http://localhost/ArcGIS/rest/services/ARCWEBSVCMAP/MapServer/6");  //success in this point
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
ILayer lyr = (ILayer)restLayer; 
compLayer = (ICompositeLayer)lyr;

//ILayer lyr = compLayer.get_Layer(0);  //errro
restSBLayer = (IMapServerSublayer2)lyr;  //error

string rclink = "2312034000";
double measure = 0.02;
ILayerDescription layerdesc = restSBLayer.LayerDescription;
layerdesc.DefinitionExpression = "RCLINK = '" + rclink + "'";
IFIDSet selectedIDs = layerdesc.SelectionFeatures;
int selectedID = -1;
selectedIDs.Next(out selectedID);
//IFeatureClass fcls = (IFeatureClass)fl;//.FeatureClass;

//double[] results = getRouteMilePointXY(fcls, rclink, measure);
//textBox1.Text = results.ToString();;
textBox1.Text = "" + selectedID;

Outcomes