1.采用HTTPS方式访问
2.请求采用POST方式
3.提交和返回结果采用XML格式
NSString *xml = @"<xml><a>aaaaa</a><b>bbbbb</b></xml>" ; //xml格式
NSString *url =@"https://api.amob.com";
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[xml dataUsingEncoding:NSUTF8StringEncoding]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
//设置返回数据格式
operation.responseSerializer= [AFHTTPResponseSerializerserializer];
//请求
operation.securityPolicy.validatesDomainName=NO;//关键语句1
operation.securityPolicy.allowInvalidCertificates=YES;//关键语句2
[operationsetCompletionBlockWithSuccess:^(AFHTTPRequestOperation*_Nonnulloperation,id_NonnullresponseObject) {
NSString*result = [[NSStringalloc]initWithData:responseObjectencoding:NSUTF8StringEncoding];
NSLog(@"AFN--成功--结果:%@----返回数据%@", result, responseObject);
}failure:^(AFHTTPRequestOperation*_Nonnulloperation,NSError*_Nonnullerror) {
NSLog(@"AFN--失败--%@", error.localizedDescription);
}];
[operationstart];