我真的被这个问题难住了。我正在使用 Restkit 访问 Web 服务。大多数操作都可以正常工作,但前两个,initializeDevice 和 insertNewPatron,不是。对于这些,会触发异步请求,但从不调用委托方法。我已经在服务器上进行了检查,没有证据表明正在拨打这些电话。我不知道这些操作有什么不同使它们不起作用。这是进行调用的类:
-(id)initForController:(UIViewController *)viewController{
self.vc=viewController;
NSString *baseURL = @"https://xxxxxxxxx/APNS_WebService/rest/operations/";
NSURL *url=[NSURL URLWithString:baseURL];
client = [RKClient clientWithBaseURL:url];
client.disableCertificateValidation=YES;
return self;
}
-(void)insertNewPatronWithCard:(NSString *)cardNumber PIN:(NSString *)pin NickName:(NSString *)nickname Device:(NSString *)deviceID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/insertNewPatron?cardNumber=%@&pin=%@&nickname=%@&deviceID=%@",cardNumber,pin,nickname,deviceID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"insertNewPatron" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)initializeDeviceWithID:(NSString *)deviceID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/initializeDevice?deviceID=%@",deviceID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"initializeDevice" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)updateDevicePreferencesWithDeviceID:(NSString *)deviceID DueDateNotice:(NSString *)dueDateNotice HoldsNotice:(NSString *)holdsNotice EventNotice:(NSString *)eventNotice{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/updateDevicePreferences?deviceID=%@&dueDateNotice=%@&holdsNotice=%@&eventNotice=%@",deviceID,dueDateNotice,holdsNotice,eventNotice]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"updateDevicePreferences" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)removeUserWithCard:(NSString *)cardNumber{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/removeUser?cardNumber=%@",cardNumber]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"removeUser" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)addEventWithDevice:(NSString *)deviceID EventID:(NSString *)eventID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/addEvent?deviceID=%@&eventID=%@",deviceID,eventID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"addEvent" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request send];
}
-(void)removeEventWithDevice:(NSString *)deviceID EventID:(NSString *)eventID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/removeEvent?deviceID=%@&eventID=%@",deviceID,eventID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"removeEvent" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)removeAllEventsWithDevice:(NSString *)deviceID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/removeAllEvents?deviceID=%@",deviceID]];
request.delegate=self;
NSDictionary *params = [NSDictionary dictionaryWithObject:@"removeAllEvents" forKey:@"operation"];
request.params=params;
[request sendAsynchronously];
}
我注意到,对于不起作用的操作,在 Restkit 日志记录中,我收到一条消息,上面写着“准备好 GET UrlRequest”,但不是那个写着“继续请求”的消息,我看到的操作是有效的。