afnetworking设置请求头代码
来源:互联网 发布:免费下载苹果软件 编辑:程序博客网 时间:2024/06/02 02:09
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", WebURL]]];
[request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
[request setTimeoutInterval: 30];
NSString*msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
[request addValue: @"text/xml; charset=utf-8"forHTTPHeaderField:@"Content-Type"];
[request addValue:@"IOS App (power by elliott)" forHTTPHeaderField:@"User-Agent"];
[request addValue:soapActionURL forHTTPHeaderField:@"SOAPAction"];
[request addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
// Make sure to set the responseSerializer correctly
//operation.responseSerializer = [AFXMLParserResponseSerializer serializer];
//
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)operation.response;
if (httpResponse.statusCode == 200) {
dispatch_async(dispatch_get_main_queue(), ^{
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:responseObject];
//[xmlParser setShouldProcessNamespaces:NO];
//[xmlParser setShouldReportNamespacePrefixes:NO];
//[xmlParser setShouldResolveExternalEntities:NO];
[xmlParser setDelegate:myhttp];
[xmlParser parse];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
});
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
DLog(@"errror: %@", error);
dispatch_async(dispatch_get_main_queue(), ^{
if (_delegate && [_delegate respondsToSelector:@selector(updateVCwithNetError: method:)]) {
[_delegate updateVCwithNetError:@"请求出错" method:myhttp.soapMethod];
}
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
});
}];
- afnetworking设置请求头代码
- AFNetworking 请求头的设置
- AFNetworking 的请求头设置
- AFNetWorking请求头的设置
- 关于AFNetworking设置Content-Type,请求头
- AFNetworking 3.0+ 设置请求头Header
- AFNetworking 请求头设计
- AFNetworking 添加请求头
- AFnetworking post 添加请求头
- AFNetWorking设置请求超时时间
- AFNetworking网络请求头的设定
- HttpClient设置请求头
- http 请求头设置
- 设置AFNetworking网络请求的超时时间
- 设置 AFNetworking 网络请求的超时时间
- 设置AFNetworking网络请求的最大时间
- NSMutableURLRequest 请求头的设置
- jQuery Ajax 设置请求头
- 谷歌官方建议笔记——布局
- mysql int(m)与int(m)的区别
- Java自带的性能监测工具用法简介——jstack、jconsole、jinfo、jmap、jdb、jsta、jvisualvm
- Android-基础复习之工程介绍
- MYSQL_FIELD
- afnetworking设置请求头代码
- 彩色图像灰度化之一 问题提出与国内外研究梗概
- Creating a Physical Standby Database 11g
- unity3d calculatepath
- 近观ArcGIS 10.3.1
- linux下目录的作用
- codeforces 558A. Lala Land and Apple Trees
- CSS3的REM设置字体大小
- HTML5 HybridApp开发上手指引