使用iphone在wcf中传递参数

时间:2013-01-24 07:50:46

标签: iphone ios ipad

我将一些参数传递给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);
    }

让我知道是否有任何问题

0 个答案:

没有答案