IOS移动端如何获取ArcGIS Server的服务列表

0
分享 2014-05-14
1、应用需求
ArcGIS Server服务器增加、删除服务,移动端能动态的获取服务列表;
2、移动端解决方法
2.1、获取服务器端服务列表URL地址
(1)打开ArcGIS Server服务目录

(2)点击rest得到服务列表URL

(3)点击rest可以看到服务列表的json串,这个url就是我们获取服务列表的url
2.2 IOS读取方法
(1)异步调用服务
//服务URL NSURL* url = [NSURL URLWithString:@"http://192.168.0.1/arcgis/rest ... ot%3B];
//self.currentJsonOp是 AGSJSONRequestOperation 对象 self.currentJsonOp = [[[AGSJSONRequestOperation alloc]initWithURL:url] autorelease];

self.currentJsonOp.target = self;
self.currentJsonOp.action = @selector(operation:didSucceedWithResponse:);
self.currentJsonOp.errorAction = @selector(operation:didFailWithError:);
//self.queue 是 NSOperationQueue 对象
//Add operation to the queue to execute in the background
[self.queue addOperation:self.currentJsonOp];
(2)处理调用结果,得到服务名称 //成功处理,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);
}
}
}
//处理失败,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];
}
这样就动态的得到了地图服务的URL列表

文章来源:http://blog.csdn.net/esrichinacd/article/details/7920694

0 个评论

要回复文章请先登录注册