/Post请求
AFHTTPRequestOperationManager *afManager = [AFHTTPRequestOperationManager manager];
// afManager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
// NSLog(@"afManager.responseSerializer.acceptableContentTypes = %@", afManager.responseSerializer.acceptableContentTypes);
// NSLog(@"afencoding = %d",operation.responseStringEncoding);
NSLog(@"af请求结果:%@ 类型:%@", responseObject, [responseObject class]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"af错误:%@",error);
}];
///soap请求
NSString *soapMsg = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap12:Envelope "
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
"xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
"<soap12:Body>"
"<getMobileCodeInfo xmlns=\"http://WebXml.com.cn/\">"
"<mobileCode>%@</mobileCode>"
"<userID>%@</userID>"
"</getMobileCodeInfo>"
"</soap12:Body>"
"</soap12:Envelope>", @"15801688609", @""];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
NSLog(@"manager.responseSerializer = %@", manager.responseSerializer);
[manager.requestSerializer setValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/soap+xml"];
[manager.requestSerializer setValue:soapMsg forHTTPHeaderField:@"Content-Length"];
NSMutableURLRequest *request = [manager.requestSerializer requestWithMethod:@"POST" URLString:@"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx" parameters:nil error:nil];
[request setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
AFHTTPRequestOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSMutableData *data = responseObject;
NSLog(@"soap succeed! = %@", responseObject);
NSLog(@"wo cao shuju shi = %@", [[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSString *response = [[NSString alloc] initWithData:(NSData *)[operation responseObject] encoding:NSUTF8StringEncoding];
NSLog(@"error = %@, %@, %@", operation, error, response);
}];
[manager.operationQueue addOperation:operation];
///