Search code examples
javascriptibm-mobilefirstmobilefirst-adapters

how to invoke java adapter procedure from client side?


I have created java adapter in MobileFirst 7.0, My problem is how to invoke Java adapter from client side (js). I found Java adapter doesn't have procedures to call from client.

Thanks in Advance :)


Solution

  • How does your Java adapter look like? which environment are you testing this in?
    Did you read the tutorial that explains how to call Java adapters in Hybrid applications?

    See here: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/server-side-development/invoking-adapter-procedures-hybrid-client-applications/

    In Java adapters, instead of "procedure name" you need to supply the @path you have set in your Java code.

    WLResourceRequest

    var resourceRequest = new WLResourceRequest(
        "/adapters/RSSReader/getFeedsFiltered",
        WLResourceRequest.GET
    );
    

    The WLResourceRequest class handles resource requests to MobileFirst adapters or external resources.

    The parameters for the constructor are:

    request URL: To access an adapter within the same project, the URL should be /adapters/AdapterName/procedureName.

    To access resources outside of the project, use the full URL.

    HTTP method: Most commonly WLResourceRequest.GET or WLResourceRequest.POST timeout: optional, request timeout in milliseconds