Objective c 无法将参数发送到目标C中的Web服务

Objective c 无法将参数发送到目标C中的Web服务,objective-c,web-services,Objective C,Web Services,无法通过请求对象发送参数。 如果我不发送参数,则我无法调用服务您正在标题中添加post值 NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:@"abcd",@"UID", nil]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xyz:8080/cde"]

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

您正在标题中添加post值

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];

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

我得到以下错误:LoginPage[19044:f803]-[\uu NSCFDictionary length]:未识别的选择器发送到实例0x6d65600 2012-10-10 14:05:17.167 LoginPage[19044:f803]***由于未捕获的异常“NSInvalidArgumentException”终止应用程序,原因:'-[\uu NSCFDictionary length]:发送到实例0x6d65600'***的无法识别的选择器第一次抛出调用堆栈:(0x14f2022 0xef2cd6 0x14F3CBD这意味着在代码的某个地方,您正在向无法响应它的对象传递一条[length]消息。请尝试调试它并打印出什么类是0x6d65600(这将是另一个指针地址),或在抛出异常上放置断点,以查看您的代码上的确切位置,您得到此错误我在异常上方的第[request setValue:dict forHTTPHeaderField:@“parameter”];0x6d65600是dict类。我这里有一个问题,我们可以在requestNo中将NSDictionary设置为HttpHeaderField的值吗?您需要插入NSString。如在方法签名中所述:-(void)setValue:(NSString*)HttpHeaderField的值:(NSString*)字段
NSMutableString *postString = @"myPostValue=value";

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