1. Application Requirements
The ArcGIS Server adds or deletes services, and the mobile end can dynamically obtain the service list;
2. Mobile Solutions
2.1 obtain the URL address of the server service list
(1) Open the ArcGIS Server Service Directory
(2) Click rest to get the service list URL
(3) Click rest to view the JSON string of the service list. This URL is the URL for getting the service list.
2.2 IOS reading Method
(1) asynchronous service call
// Service URL
Nsurl * URL = [Nsurl Urlwithstring: @ "http: // 192.168.0.1/ArcGIS/rest/services? F = pjson "];
// Self. currentjsonop is Agsjsonrequestoperation object Self. currentjsonop = [[Agsjsonrequestoperation Alloc] initwithurl: url] Autorelease];
Self.currentjsonop.tar get = Self;
Self. currentjsonop. Action = @ Selector (Operation: didsucceedwithresponse :);
Self. currentjsonop. erroraction = @ Selector (Operation: didfailwitherror :);
// Self. queue is the nsoperationqueue object
// Add Operation To The Queue To Execute In
The Background
[Self. Queue Addoperation: Self. currentjsonop];
(2) process the call result and obtain the service name.
// The WebService was invoked successfully.
- (Void) operation :( nsoperation *) OP Didsucceedwithresponse :( nsdictionary *) Weatherinfo {
// Print The Response To See What The JSON
Payload Looks Like.
Nslog (@ "% @", Weatherinfo );
Nslog (@ "Number Is % D ", weatherinfo. Count );
If ([weatherinfo Objectforkey: @ "services"]! = Nil ){
Nsarray * Servicesarray = [weatherinfo
Objectforkey: @ "services"];
Nslog (@ "% @, lenth Is % D ", Servicesarray, [servicesarray Count]);
For (Int I = 0; I <[servicesarray Count]; I ++)
{
Nsdictionary * Services = [servicesarray Objectatindex: I];
// Nslog (@ "% @", Services );
Nsstring * Name = [Services Objectforkey: @ "name"];
Nsstring * Type = [Services Objectforkey: @ "type"];
Nslog (@ "% @, % @", name, type );
}
}
}
// Processing failed, error encountered while invoking WebService. Alert user
- (Void) operation :( nsoperation *) OP Didfailwitherror :( nserror *) Error {
Self. mapview. callout. Hidden = Yes;
Uialertview * AV = [[Uialertview Alloc] Initwithtitle: @ "sorry"
Message: [Error Localizeddescription]
Delegate: Nil Cancelbuttontitle: @ "OK"
Otherbuttontitles: Nil] Autorelease];
[AV Show];
}
In this way, the URL list of the map service is obtained dynamically.