在我的C#应用程序中,我试图访问arcgis.com上托管的功能服务。要素服务仅与组或组织共享,并且不公开。如何在客户代码中访问此服务。这是我的客户端代码,引发异常,要求提供身份验证令牌。我确实有令牌,但是不知道如何使用该令牌进行身份验证才能使用该服务。对于作为PUBLIC共享的服务,该代码也可以正常运行。
IPropertySet sipPS = new PropertySet();
sipPS.SetProperty("DATABASE", layerUrl);
IWorkspaceFactory sipWSF = (IWorkspaceFactory)new ESRI.ArcGIS.Carto.FeatureServiceWorkspaceFactory();
IWorkspace sipWS = sipWSF.Open(sipPS, 0);
IFeatureWorkspace sipFWS = (IFeatureWorkspace)sipWS;
IGroupLayer grpLayer = new GroupLayerClass();
grpLayer.Name = Constants.ArcGISOnlineGroupLayerName;
IFeatureClass sipFC = sipFWS.OpenFeatureClass("0");
IFeatureLayer fl = new FeatureLayerClass();
fl.Name = featureLayerName;
fl.FeatureClass = sipFC;
grpLayer.Add(fl as ILayer);