0
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:@"abcd",@"UID", nil];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xyz:8080/cde"] ];
[request setHTTPMethod:@"POST"];
[request setValue:dict forHTTPHeaderField:@"parameter"];
[request setValue:@"get-employee-details" forHTTPHeaderField:@"serviceName"];
//[request setValue:@"pk703s" forHTTPHeaderField:@"ATTUID"];
AFHTTPRequestOperation *oper = [[AFHTTPRequestOperation alloc]initWithRequest: request] ;

[oper setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog(@"Success");
    NSLog(@"operation hasAcceptableStatusCode: %d", [operation.response statusCode]);
    NSLog(@"response STring: %@ ", operation.responseString);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Failure");
    NSLog(@"response: %@", operation.responseString);
    NSLog(@"erro: %@", error.description);
}];
[oper start];

无法通过请求对象发送参数。如果我不发送参数,那么我无法调用服务

4

1 回答 1

0

您正在标题中添加帖子值。

NSMutableString *postString = @"myPostValue=value";

[request setHTTPMethod:@"POST"];
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];

如果您仍然有问题,请从服务器端检查您得到的

于 2012-10-10T08:09:01.527 回答