NSDictionary is empty when i use JSONValue to response string from SOAP WebService

pamelagorilla

New Member
Currentyl i am developing IOS application using XCode4.2.1. My application is grabbing json value from asp.net web service. Here is my code to grab web service.\[code\]-(BOOL)GrabbingStudentsWebService{NSURL *url=[NSURL URLWithString:@"http://www.cheaptal.com/easypft/Service1.asmx"];ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];[request setRequestMethod:@"POST"];[request addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];[request addRequestHeader:@"SOAPAction" value:@"http://cheaptal.com/GetAllStudents"];NSString *soapMsg= [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" "<soap:Body>" "<GetAllStudents xmlns=\"http://cheaptal.com/\" />" "</soap:Body>" "</soap:Envelope>"];NSString *messageLength = [NSString stringWithFormat:@"%d",[soapMsg length]];[request addRequestHeader:@"Content-Length" value:messageLength];[request appendPostData:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];[request setDelegate:self]; [request startAsynchronous]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];hud.labelText = @"Sync...";return TRUE;}\[/code\]Here is my request finished code\[code\]- (void)requestFinished:(ASIHTTPRequest *)request{ [MBProgressHUD hideHUDForView:self.view animated:YES];if (request.responseStatusCode == 200) { NSString *response = [request responseString]; txtview.text = response; NSDictionary *insidejson=[[NSDictionary alloc] init]; insidejson = [response JSONValue]; //my problem is here.} else { txtview.text = @"cannot retrieve data.";}}\[/code\]here is the response code from web service:\[code\]<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAllStudentsResponse xmlns="http://cheaptal.com/"><GetAllStudentsResult>[{"stu_name":"COEMAW","stu_sitreach":10.5,"stu_broadjump":12.3,"stu_napfarun":"11:54.32"},{"stu_name":"LINA","stu_sitreach":2.5,"stu_broadjump":5.3,"stu_napfarun":"10:54.22"},{"stu_name":"ULD27","stu_sitreach":6.5,"stu_broadjump":7.3,"stu_napfarun":"09:54.12"},{"stu_name":"MOTTA","stu_sitreach":7.5,"stu_broadjump":9.3,"stu_napfarun":"10:33.52"}]</GetAllStudentsResult></GetAllStudentsResponse></soap:Body></soap:Envelope>\[/code\]my problem is when i try to parse response string to NSDictionary from using JSONValue (insidejson = [response JSONValue];), there is no value inside in insidejson variable. i still don't know why insidejson is empty.here is my web service link: http://www.cheaptal.com/easypft/Service1.asmxReally appreciate for your help!dartfrog
 
Back
Top