webservice返回json数据 - (IBAction)webServicexRequestPost:(UIButton *)sender{ //构建webservice请求字符串 NSLog(@"开始构建字符串"); NSString*soapMessage=[NSString stringWithFormat:<pre class="brush:objc; toolbar: true; auto-links: false;"> 请把代码粘贴在这里<pre class="brush:objc; toolbar: true; auto-links: false;"> 请把代码粘贴在这里 <pre class="brush:objc; toolbar: true; auto-links: false;"> 请把代码粘贴在这里 </pre> </pre> </pre> @"{\"Username\":\"%@\", \"Password\":\"%@\"}",self.UserName.text,self.PassWord.text]; NSString*msgLength=[NSString stringWithFormat:@"%d",[soapMessage length]]; NSLog(@"调用webservice的字符串是%@",soapMessage); //设置请求地址 NSURL*url=[NSURL URLWithString:@"http://XXXXXXXX/Login"]; NSMutableURLRequest*urlRequest=[NSMutableURLRequest requestWithURL:url]; //请求头文件 [urlRequest addValue: @"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [urlRequest addValue: @"Login" forHTTPHeaderField:@"SOAPAction"]; [urlRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; //设置请求方式 [urlRequest setHTTPMethod:@"POST"]; [urlRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSURLResponse *response; NSError*error=nil; //接受返回数据 NSData*responseData=[NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error]; NSMutableString*result=[[NSMutableString alloc]initWithData:responseData encoding:NSUTF8StringEncoding ]; NSLog(@"return string is============>>%@",result); //解析返回的数据 SBJsonParser*parser=[[SBJsonParser alloc]init ]; NSError*JSONError=nil; NSMutableDictionary*jsonDil=[parser objectWithString:result error:&JSONError ]; NSLog(@"%@",[jsonDil objectForKey:@"d"]); } 这样返回的就是一个json的数据结构