【发布时间】:2014-07-14 07:55:18
【问题描述】:
我有 WCF Web 服务,它接受电子邮件地址,如果数据库中不存在该条目,则返回“True”,如果存在,则返回“False”。当我使用 fiddler 和 POST 数据进行服务时,它返回结果为预期,当我尝试从我的 iPad 应用程序发送请求时,它只会说“无效的 JSON 原语:电子邮件。”。
服务链接: http://www.unluapps.com/Service1.svc/CheckRejected
用于测试的 JSON:
{"Email":"test@unluco.com"}
IOS代码:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSError *e = nil;
NSDictionary *parameters = [NSJSONSerialization JSONObjectWithData: [[NSString stringWithFormat:@"{\"Email\":\"%@\"}",_TxtMail.text] dataUsingEncoding:NSUTF8StringEncoding]
options: NSJSONReadingMutableContainers
error: &e
];
[manager POST:@"http://www.unluapps.com/Service1.svc/CheckRejected" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
// NSLog(@"JSON: %@", responseObject);
_receivedData=responseObject;
//NSLog(@"%@",[responseObject objectForKey:@"CheckifExistsResult"]);
NSLog(@"%@",[responseObject objectForKey:@"CheckRejectedResult"]);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}
];
【问题讨论】:
-
这个 url unluapps.com/Service1.svc/CheckRejected 没有得到响应。 404错误
-
我已经说过我在问题中使用 POST。
标签: c# ios json wcf afnetworking