WLClient addGlobalHeader 不起作用

WLClient addGlobalHeader does not work

我正在尝试设置全局 headers 以将特定的安全信息发送到后端适配器。这似乎不适用于使用 Objective-C 的本机 iOS 应用程序。我确定,我错过了一些东西。

这是我的简单示例:

NSLog(@"Invoking Procedure...");
WLProcedureInvocationData *myInvocationData = [[WLProcedureInvocationData alloc] initWithAdapterName:@"RSSReader" procedureName:@"getStories"];
MyInvokeListener *invokeListener = [[MyInvokeListener alloc] initWithController: self];
[[WLClient sharedInstance] addGlobalHeader:@"header1" headerValue:@"header1"];
[[WLClient sharedInstance] invokeProcedure:myInvocationData withDelegate:invokeListener];

发送的header根本没有变化。

您如何检查 headers 是否已发送?
MobileFirst 的具体版本是什么?

我重现的步骤:

  • 运行 MobileFirst Studio 6.3.0.00.20150130-1638
  • 我已经下载了 ios 示例中的调用 (https://ibm.biz/BdEw79)
  • 在我的 doInvokeProcedure 中添加了你的 addGlobalHeader 行:

    - (IBAction)doInvokeProcedure:(UIButton *)sender {
    [self updateView:@"Invoking Procedure..."];
    NSLog(@"Invoking Procedure...");
    WLProcedureInvocationData *myInvocationData = [[WLProcedureInvocationData alloc] initWithAdapterName:@"RSSReader" procedureName:@"getStories"];
    MyInvokeListener *invokeListener = [[MyInvokeListener alloc] initWithController: self];
    [[WLClient sharedInstance] addGlobalHeader:@"header1" headerValue:@"header1"];
    [[WLClient sharedInstance] invokeProcedure:myInvocationData withDelegate:invokeListener];
    
    }
    
  • 在 WireShark 中捕获流量:

    POST /InvokingAdapterProceduresNative/apps/services/api/InvokingAdapterProceduresiOS/iOSnative/query HTTP/1.1
    Host: localhost:10080
    X-Requested-With: XMLHttpRequest
    User-Agent: InvokingAdapterProceduresiOS/1.0 (iPhone Simulator; iOS 8.1; Scale/2.00)/WLNativeAPI/6.3.0.00.20150130-1638
    Cookie: WL_PERSISTENT_COOKIE=279ea643-f731-4c5e-8a59-74ed4842b3d8; JSESSIONID=0000x8PNWpTDWKW73FnPaw9oTAm:42599173-098f-4ab1-b562-68c6a8e1f345
    WL-Instance-Id: 7kreem49ql20l2pdf1fuq9q0kc
    x-wl-clientlog-osversion: 8.1
    x-wl-clientlog-env: iOSnative
    header1: header1
    x-wl-clientlog-deviceId: 18A44BA7-4DF9-411B-9577-5954C8E44921
    x-wl-clientlog-model: x86_64
    x-wl-analytics-tracking-id: 6D6B72FD-820C-4EF8-AE45-205723E464FF
    Content-Length: 112
    Connection: keep-alive
    x-wl-clientlog-appname: InvokingAdapterProceduresiOS
    x-wl-platform-version: 6.3.0.00.20150130-1638
    Accept-Language: en
    x-wl-clientlog-appversion: 1.0
    Accept: */*
    Content-Type: application/x-www-form-urlencoded; charset=utf-8
    Accept-Encoding: gzip, deflate
    x-wl-app-version: 1.0
    

注意中间的header1: header1