使用AFNetworking无法获得对jsp调用的响应

时间:2014-04-18 12:17:07

标签: ios objective-c afnetworking-2

以下是我的jsp call

NSString *strURL = [NSString stringWithFormat:@"https://xxx.com/xx/jsp/Implementation/getMyResource.jsp?uid=xxxxx"];
NSURL *urlLink = [[NSURL alloc] initWithString:strURL];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlLink];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
operation.responseSerializer = [AFXMLParserResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSXMLParser *xmlParser = (NSXMLParser*)responseObject;
    NSLog(@"%@",xmlParser);

    NSError * parsedError = nil;

    NSDictionary *dictUserDetails = [XMLReader dictionaryForNSXMLParser:xmlParser error:&parsedError];

    if (parsedError == nil) {
        NSLog(@"%@",dictUserDetails);
    }
    else
    {
        NSLog(@"wrong while parsing xml data");
    }

} failure:^(AFHTTPRequestOperation *request, NSError *error){
    NSLog(@"Error:------>%@", [error description]);
}];

No response。立即paste strURL link web browser get response no problem url {{1}} {/ 1}}。

1 个答案:

答案 0 :(得分:0)

您需要将AFHTTPRequestOperation添加到队列中:

[[NSOperationQueue mainQueue] addOperation:operation];

请参阅https://github.com/AFNetworking/AFNetworking#get-with-afhttprequestoperation