-2
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);
我想張貼對Web服務的用戶名和密碼JSON對象的問題..但它給出了一個模糊的輸出..任何人都可以幫助我在此我已經張貼JSON對象
Output:
2013-05-14 18:50:17.155 UWUI[6226:11303] .....{
"user_email" = user;
"user_password" = password;
}....
2013年5月14日18:50:18.233 UWUI [6226:11303] **
後跟一個XML格式的內容
**
沒有朋友。不過我得到了「responseString」的XML輸出.. – Mano 2013-05-15 04:20:25