码迷,mamicode.com
首页 > Web开发 > 详细

soap request by afnetworking2.X/3.X

时间:2016-01-03 12:47:00      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

for 2.X 参考 http://jiapumin.iteye.com/blog/2109378

 1 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
 2 manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
 3 [manager.requestSerializer setValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
 4 [manager.requestSerializer setValue:soapLength forHTTPHeaderField:@"Content-Length"];
 5 NSMutableURLRequest *request = [manager.requestSerializer requestWithMethod:@"POST" URLString:@"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx" parameters:nil];
 6 [request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
 7 AFHTTPRequestOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
 8     NSString *response = [[NSString alloc] initWithData:(NSData *)responseObject encoding:NSUTF8StringEncoding];
 9     NSLog(@"%@, %@", operation, response);
10 } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
11     NSString *response = [[NSString alloc] initWithData:(NSData *)[operation responseObject] encoding:NSUTF8StringEncoding];
12     NSLog(@"%@, %@", operation, error);
13 }];
14 [manager.operationQueue addOperation:operation];
15 }

for 3.X (未验证)

1     AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
2     NSMutableURLRequest *request = [manager.requestSerializer requestWithMethod:@"post" URLString:@"" parameters:nil error:nil];
3     [request setHTTPBody:nil];
4     NSURLSessionTask *task = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
5         
6     }];
7     [task resume];

 

soap request by afnetworking2.X/3.X

标签:

原文地址:http://www.cnblogs.com/n1ckyxu/p/5095964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!