Trouble loading secure layers in AWS ArcGIS Server

1256
1
08-23-2016 12:47 AM
ShiminCai
Occasional Contributor III

Hi All,

I tried the below code to load secure feature service layers from our ArcGIS Server hosted in Amazon Web Service and got the error "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 310.)".

     NSString *userName = @"TestUser12345";

     NSString *password = @"TestUser12345";

     AGSCredential *credential = [[AGSCredential alloc]initWithUser: userName password: password];

     NSString *url = @"http://awsgis.fcnsw.com.au/arcgis/rest/services/Test/HFDPlanning_Test/FeatureServer";

     //NSString *url = @"http://203.8.108.10/arcgis/rest/services/Test/HFDPlanning_Test/FeatureServer";

     self.gdbTask = [[AGSGDBSyncTask alloc]initWithURL:[NSURL URLWithString:url] credential:credential];

    

     __weak GenericModule102ViewController *weakSelf = self;

     self.gdbTask.loadCompletion = ^(NSError* error)

     {

         if(error)

         {

             NSLog(@"%@", error.localizedDescription);

         }

    

         for (AGSMapServiceLayerInfo* info in weakSelf.gdbTask.featureServiceInfo.layerInfos)

         {

             NSURL* url = [weakSelf.gdbTask.URL URLByAppendingPathComponent:[NSString stringWithFormat:@"%lu",(unsigned long)info.layerId]];

             AGSFeatureLayer* fl = [AGSFeatureLayer featureServiceLayerWithURL:url mode:AGSFeatureLayerModeOnDemand credential:credential];

             fl.outFields = @[@"*"];

             fl.delegate = weakSelf;

             fl.editingDelegate = weakSelf;

             [weakSelf.mapView addMapLayer: fl withName:info.name];

         }

    };

The code worked fine if the feature service was not secured and also worked ok with the same secured feature service on our internal ArcGIS Server (the commented-out url above).

Could anybody shed any light on what I need to do to get it to work?

Thanks,

Shimin

0 Kudos
1 Reply
ShiminCai
Occasional Contributor III

Get it to work using line:

AGSCredential *credential = [[AGSCredential alloc]initWithUser: userName password: password authenticationType:AGSAuthenticationTypeToken tokenUrl:[NSURL URLWithString:tokenURL]];

Cheers.

0 Kudos