johnpet的webservice电话

时间:2014-10-29 12:29:17

标签: ios webservice-client

我已经坚持这个问题好几周了所以我真的很感激一些帮助。我尝试使用我正在开发的ios应用程序发送HTTP Post但是推送从未到达服务器,尽管我确实得到了代码200作为响应(来自URL连接)。

1 个答案:

答案 0 :(得分:0)

-(void)webservice_Call

{

  NSString *urlString=@"http://api.openweathermap.org/data/2.1/find/city?lat=10.369&lon=122.5896";

  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
                                                       cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
                                                   timeoutInterval:10];

  [request setHTTPMethod: @"GET"];

  NSError *requestError;

  NSURLResponse *urlResponse = nil;


  NSData *response1 = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];

  NSDictionary *resDictionary = [NSJSONSerialization JSONObjectWithData:response1 options:NSJSONReadingMutableContainers error:Nil];

}