0

我得到了一个 asp.net wcf 服务页面的 url,它接受一些参数作为 POST。但是当我尝试访问它时收到错误代码 400。网址:

http://domain.w04.wh-2.com/IBServiceHost/IBService.svc/AddTask

我还被告知要发布 json 如下

{  
     "TaskId":"23",  
     "TaskDate":"6/27/2013",  
     "TaskDesc":"Test task",  
     "TaskName":"TestName",  
     "TaskStatus":true,  
     "ProjectId":"24",  
      "DbState":"Added"  
} 

我访问服务的代码:

AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://mydomain.w04.wh-2.com"]];
        client.parameterEncoding = AFJSONParameterEncoding;
        NSMutableURLRequest *request =
        [client requestWithMethod:@"POST" path:@"/IBServiceHost/IBService.svc/AddTask" parameters:dictTask];

        AFJSONRequestOperation *operation =
        [AFJSONRequestOperation JSONRequestOperationWithRequest:request
                                                        success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON)
         {
             NSLog(@"JSON: %@", [JSON valueForKeyPath:@"LoginResult"]);
             NSLog(@"Code: %@", [[[JSON valueForKeyPath:@"LoginResult"] valueForKeyPath:@"Code"] stringValue]);
             NSLog(@"FaultString: %@", [[JSON valueForKeyPath:@"LoginResult"] valueForKeyPath:@"FaultString"]);
         }
                                                        failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON)
         {
             NSLog(@"request %@",request);
             NSLog(@"response %@",response);
             NSLog(@"error %@",error);
             NSLog(@"error opening connection");
         }];
        [operation start];
4

0 回答 0