In my app i am using SBJson for parsing the values. The web services are developed in dot net. With php web services the code was working quite fine but with dot net web services this is not showing the response values. There is no error or exception or warning in the code.
This is the JSON Output of the web service:
{ “Head”:[ { “id”:”0″,”msg”:”Username or Password Not Match”} ]}
the user name password is wrong here but my code is not even returning any wrong value.
This one is my code:
NSString *post = [NSString stringWithFormat:@"key=%@&username=%@&password=%@",key.text,[txtUsername text],[txtPassword text]];
NSLog(@"PostData: %@",post);
NSURL *url = [NSURL URLWithString:@"http://jabdcdfddfsd.aspx"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSLog(@"%@", postData);
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSLog(@"%@",postLength);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSLog(@"%@",request);
NSError *error = [[NSError alloc] init];
NSHTTPURLResponse *response = nil;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"%@",response);
NSLog(@"Response code: %d", [response statusCode]);
if ([response statusCode] >=200 && [response statusCode] <300)
{
NSString *responseData = [[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"Response ==> %@", responseData)
Help Me Out. the responseData is printing nothing. There is any problem in my code or the problem is on other end i mean in dotnet web service.
I think if the code worked fine with the old php webservice you should take a long hard look at your .Net webservice. It is highly likely that it is different in some respect. Try using something like the Chrome Advanced REST client to see how each webservice responds.