WL 6.0.0.1 iOS本机API身份验证失败

时间:2013-12-05 00:30:22

标签: ios xcode ibm-mobilefirst worklight-adapters worklight-security

我们在Worklight项目中有一个“iPhone”环境,我们在XCode 5中使用本机iOS客户端开发。尽管在Worklight控制台中禁用了App身份验证,但我们收到了身份验证错误。

我们遵循的步骤是:

  1. wlConnectWithDelegate:
  2. 上调用WLClient sharedInstance方法
  3. wlConnectWithDelegate成功后,我们使用invokeProcedure:withDelegate:
  4. 调用我们的适配器程序

    代码如下所示:

    #import <BlocksKit/A2DynamicDelegate.h>
    
    + (void) connectToWorklightOnSuccess: (SuccessBlock) success onFailure: (FailureBlock) failure {
        WLClient *client = [WLClient sharedInstance];
        A2DynamicDelegate *dd = [client dynamicDelegateForProtocol: @protocol(WLDelegate) ];
        [dd implementMethod: @selector(onSuccess:) withBlock: success];
        [dd implementMethod: @selector(onFailure:) withBlock: failure];
    
        [client wlConnectWithDelegate:(id <WLDelegate>)dd];
    }
    
    + (void) invokeProcedure: (WLProcedureInvocationData *) proc onSuccess: (SuccessBlock) success onFailure: (FailureBlock) failure {
        [WJServiceGateway connectToWorklightOnSuccess:^(WLResponse *response) {
            NSLog(@"WLClient connect succeeded");
            WLClient *client = [WLClient sharedInstance];
            A2DynamicDelegate *dd = [client dynamicDelegateForProtocol: @protocol(WLDelegate) ];
            [dd implementMethod: @selector(onSuccess:) withBlock: success];
            [dd implementMethod: @selector(onFailure:) withBlock: failure];
            [client invokeProcedure:proc withDelegate:(id<WLDelegate>) dd];
        } onFailure:^(WLFailResponse *failResponse) {
            NSLog(@"WLClient connect failed: %@", failResponse);
            [failure invoke];
        }];
    }
    

    我们invokeProcedure:onSuccess:onFailure:方法的第一次时间,我们收到错误回复:

    Status: 403
    InvocationResult: (null)
    InvocationContext: (null)
    Response text: /*-secure-
    {"WL-Authentication-Failure":{"wl_antiXSRFRealm":{"reason":"illegal state"}}}*/
    Error code: 0
    Error message: (null)
    

    在应用程序被终止并重新启动之前,后续调用会成功完成。

    此问题可能与这些问题有关(事实上,这是同一项目中发生的问题):

    但看起来很奇怪的是,我们禁用了App身份验证(使用Worklight控制台中的下拉选项)并且仍然看到身份验证错误。这个WL-Authentication-Failure /“非法状态”响应是否有其他来源?

    我们是否正在使用我们的连接并在此处调用错误?是否有一个解决方案,以便在应用程序启动后调用我们的第一个适配器不会失败?

1 个答案:

答案 0 :(得分:0)

如评论中所述,这与应用程序真实性保护无关。

  • 您需要首先调用连接到Worklight Server,并在其成功回调中调用适配器过程

  • 您也可以仅在应用程序启动时连接到Worklight Server,稍后在需要执行适配器过程调用时连接。

有关在本机iOS应用中连接和调用的工作示例,请参阅以下教程和示例:https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-6-3/server-side-development/invoking-adapter-procedures-native-ios-applications/