我正在将一些参数传递给 wcf 服务以获取数据,一切都运行良好,但我没有获取数据。我想检查参数如何调用服务并对其进行调试。任何人都可以让我知道如何检查它。请在下面找到我的代码供您参考。
NSArray *propertyNames = [NSArray arrayWithObjects:@"studentID", nil];
NSArray *propertyValues = [NSArray arrayWithObjects:@"E6A83233-7D7F-49AF-B54E-375BBF3E3E59", nil];
NSDictionary *properties = [NSDictionary dictionaryWithObjects:propertyValues forKeys:propertyNames];
// NSMutableDictionary* personObject = [NSMutableDictionary dictionary];
// [personObject setObject:properties forKey:@"person"];
NSMutableArray * arr;
//[arr addObject: personObject];
arr=[[NSMutableArray alloc]initWithObjects:properties, nil];
NSLog(@"%@",arr);
// NSString *jsonString = [personObject JSONRepresentation];
//NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError * error;
NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:arr options:NSJSONWritingPrettyPrinted error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://parentportal.technologyorg.com/parentportal.svc/GetSchoolEvents"]];
NSString *jsonString = [[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
[request setValue:jsonString forHTTPHeaderField:@"json"];
[request setHTTPMethod:@"Post"];
[request setHTTPBody:jsonData2];
NSLog(@"JSON String: %@",jsonString);
NSError *errorReturned = nil;
NSURLResponse *theResponse =[[NSURLResponse alloc]init];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&errorReturned];
if (errorReturned) {
//...handle the error
NSLog(@"error");
}
else {
NSString *retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//...do something with the returned value
NSLog(@"RETVAL%@",retVal);
}
让我知道是否有任何问题