Search code examples
iosdictionaryproxyarcgis

how to load Arcgis map via proxy.ashx in iOS application?


I am working on iOS app that uses AGSRuntime Environment API for iOS to load a map layers (dynamic and features layers) via a .Net proxy called "proxy.ashx" . As in the following code lines:

NSString *MAPServiceURL = @"https://myDomain/sourceCodePath/proxy.ashx?http://my_ArcGis_Server/arcgis/rest/services/MapService/MapServer/"
NSString *FeatureLayerURL = @"https://myDomain/sourceCodePath/proxy.ashx?http://my_ArcGis_Server/arcgis/rest/services/MapService/MapServer/0"
self.dynamicLayer = [AGSDynamicMapServiceLayer dynamicMapServiceLayerWithURL:[NSURL URLWithString:MAPServiceURL]];

self.featureLayer = [[AGSFeatureLayer alloc] initWithURL:[NSURL URLWithString:FeatureLayerURL] mode:AGSFeatureLayerModeSnapshot];

My Problem is that the dynamic layer does not appear. and no error happens on the iOS app side.

On the proxy.ashx side it redirects the request and returns the response (OK 200) as HTML Page.

Note: the same map loaded successfully in a web application uses AGSRuntime Environment API for JavaScript via the same "proxy.ashx".

So, what is my mistake?


Solution

  • I found that when app request in POST the NSURLConnection will remove the unwanted parameter from URL (everything after the ? because it is GET parameter). So you can try to set the map service URL without the proxy URL.

    NSString *mapServiceURL = @"http://my_ArcGis_Server/arcgis/rest/services/MapService/MapServer/";
    

    Or you can use ArcGIS Web Adaptor for public access to your intranet ArcGIS server, if you don't want to set your ArcGIS server as public domain.