NSString *username = @"user";
NSString *password = @"password";
NSMutableDictionary *dictionnary = [NSMutableDictionary dictionary];
[dictionnary setObject:username forKey:@"user_email"];
[dictionnary setObject:password forKey:@"user_password"];
NSLog(@".....%@....",dictionnary);
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionnary
options:kNilOptions
error:&error];
NSString *urlString = @"http://abcd.com/SVCs/WSUserService.svc/MobSignIn";
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:jsonData];
NSURLResponse *response = NULL;
NSError *requestError = NULL;
NSData *responseData = [NSURLConnection
sendSynchronousRequest:request
returningResponse:&response
error:&requestError];
NSString *responseString = [[NSString alloc]
initWithData:responseData
encoding:NSASCIIStringEncoding] ;
NSLog(@"%@", responseString);
我想将具有用户名和密码的 json 对象发布到 Web 服务.. 但它给出了一个模糊的输出.. 任何人都可以帮我解决这个问题
Output:
2013-05-14 18:50:17.155 UWUI[6226:11303] .....{
"user_email" = user;
"user_password" = password;
}....
2013-05-14 18:50:18.233 UWUI[6226:11303]  **
后跟一个xml格式的内容
**