Xcode 使用MKNetworkoperation调用web服务
在我们的开发团队中,我们实现了一个WEB服务,该服务将对客户端进行身份验证。 从iPhone应用程序中,我们需要将客户端信息发送到web服务,为此,我编写了以下函数Xcode 使用MKNetworkoperation调用web服务,xcode,web-services,mknetworkkit,Xcode,Web Services,Mknetworkkit,在我们的开发团队中,我们实现了一个WEB服务,该服务将对客户端进行身份验证。 从iPhone应用程序中,我们需要将客户端信息发送到web服务,为此,我编写了以下函数 -(void)authenticateClient:(NSString*)theContractNumber ClientCode:(NSString*)theClientCode CellPhone:(NSString*)theCellPhone apple
-(void)authenticateClient:(NSString*)theContractNumber
ClientCode:(NSString*)theClientCode
CellPhone:(NSString*)theCellPhone
appleID:(NSString*)theAppleID
{
NSLog(@"Begin Send the information to the Web Service",nil);
NSString *uid = [UIDevice currentDevice].uniqueIdentifier;
NSDictionary *formParams = [NSDictionary dictionaryWithObjectsAndKeys:
theClientCode, @"ClientCode",
theContractNumber, @"ContractCode",
theAppleID, @"AppleID",
@" ", @"AndroidID",
@" ", @"WindowsID",
uid, @"AppleDeviceID",
@" ", @"AndroidDeviceID",
@" ", @"WindowsDeviceID",
theCellPhone, @"TelephoneNumber"
, nil];
MKNetworkOperation *operation = [self.engine operationWithPath:@"/services/Authentication.ashx"
params: formParams
httpMethod:@"POST"];
[operation addCompletionHandler:
^(MKNetworkOperation *operation) {
NSLog(@"%@", [operation responseString]);
}
errorHandler:^(MKNetworkOperation *errorOperation, NSError *error) {
NSLog(@"%@", error);
}];
[self.engine enqueueOperation:operation] ;
}
该函数可以工作(或者看起来没有错误),但实际上它什么都不做。它从[operation addCompletionHandler:块传递,但它什么也不做。我也一步一步地执行了它,再次看到应用程序到达这一行,然后执行它,直接进入[self.engine enqueueOperation:operation]行,而不进入代码块
有人能帮忙吗
谢谢。我不想相信没有人使用addCompletionHandler中的MKNetworkKit?代码块会在收到服务器的响应后调用。