在 "desktop" 中调用适配器不起作用

Calling adapters in "desktop" does not work

使用 IBM MobileFirst 7.1

我创建了一个非常简单的混合项目。然后添加了一个非常简单的java适配器:

@Path("/hello")
public class BrokenAdapterResource {
    @GET
    @Produces("text/plain")
    public String hello() {
        return "Hope keeps man alive....!";
    }
}

并且还创建了一个 MobileFirst 环境:"Desktop Browser web page"。我尝试调用适配器。当我从 "common" 调用它时,它按预期工作。但是,当我从 "desktop" 调用它时,它不起作用:

var resourceRequest = new WLResourceRequest(
        "/adapters/BrokenAdapter/hello",
        WLResourceRequest.GET);



resourceRequest.send().then(
        function(result){
            var data = JSON.parse(JSON.stringify(result))
            var message = data['responseText']
            $("#message").text(message) //Set the value in message div tag              
        },
        function(error){
            $("#message").text(JSON.stringify(error))
        }
    );

在 "common" 中,我得到了预期的结果: Hope keeps man alive....! 。 在 "desktop" 我总是得到 {"status":200,"responseHeaders":{},"responseText":"undefined","errorCode":"API_INVOCATION_FAILURE","errorMsg":"Unsupported environment","invocationContext":null}

我想知道如果在这种情况下错了怎么办?这是调用资源的正确方式吗?

我创建了一个示例项目来展示这个东西https://hub.jazz.net/project/ignacio4d/BrokenProject/overview

请看以下教程:https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/server-side-development-category/invoking-adapter-procedures-hybrid-client-applications/

具体来说:

MobileFirst applications can access resources using the WLResourceRequest REST API. The REST API works with all adapters and external resources, and is supported in the following hybrid environments: iOS, Android, Windows Phone 8, and Windows 8.

If your application supports other hybrid environments such as BlackBerry, Mobile Web, or Desktop Browser, see the tutorial for IBM MobileFirst Platform Foundation 6.3.

换句话说,Java 个适配器使用 WLResourceRequest。 Java 适配器不支持桌面浏览器环境。解决方法是使用支持 WL.Client.invokeProceudreWLResourceRequest 的 Java 脚本适配器,这样您就可以在桌面浏览器环境中使用常规 WL.Client.invokeProcedure