在我的 Iphone 应用程序中,我使用 AFNetworking 将一些数据发布到网络服务并取回一些数据......
这是我的例子,我总是得到“假”作为回应,我做错了什么?
NSURL *baseURL = [NSURL URLWithString:@"http://myPath/Iphone/method"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
[httpClient defaultValueForHeader:@"Accept"];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
[udid copy], @"uuid",
nil];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"http://myPath/Iphone/method" parameters:params];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[httpClient registerHTTPOperationClass:[AFXMLRequestOperation class]];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
response = [operation responseString];
NSLog(@"response: %@",response);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", [operation error]);
}];
[operation start];
编辑:我在 Url 中调用的方法返回一个字符串(没有字符串不是假的)
[HttpPost]
public bool checkIphone(string uuid)
{
IDictionary<string,object> check = Request.Properties;
uuid = check["uuid"].ToString();
//do anything with the uuid
if (1<0)
{
return true;
}
else
{
return false;
}
}
我用我的iphone调用这个方法,通常它应该返回xml或者?