More detailed research and searching for AFNetworking documents on Stackoverflow gave me the SOLUTION :
1. The parameters for the request should be as follows:
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: [NSDictionary dictionaryWithObjectsAndKeys: username.text, @"UserNameOrEmail", password.text, @"Password", nil], @"request", nil];
2.Create an AFHTTPClient
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL: [NSURL URLWithString:@"http://server"]];
3. When I send JSON as parameters, I have to add:
client.parameterEncoding = AFJSONParameterEncoding;
After that I got rid of the 404 error, but I could not do anything with the JSON response, I do not know why. But the solution:
4.Create a request:
NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/ProfileWebService.svc/login" parameters:params];
5. Creating an operation:
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSLog(@"JSON: %@", [JSON valueForKeyPath:@"LoginResult"]); NSLog(@"Code: %@", [[[JSON valueForKeyPath:@"LoginResult"] valueForKeyPath:@"Code"] stringValue]); NSLog(@"FaultString: %@", [[JSON valueForKeyPath:@"LoginResult"] valueForKeyPath:@"FaultString"]); } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"error opening connection"); }];
6. Run the operation:
[operation start]
Hope that AFNetworking newbies find this post helpful.