IBM Worklight 6.1 - How to send post values in adapter?

放肆的年华 提交于 2019-12-31 03:22:07

问题


I'm using IBM worklight 6.1 for my mobile app project. My question is how to send post values in adapter?

function getUsername(userAlias,locale) {
    path = "rest-rib/service/Login/login_username";

    var input = {
        method : 'post',
        returnedContentType : 'json',
        path : path
    };


    return WL.Server.invokeHttp(input);
}

Thanks a lot in advance.


回答1:


Your question does not specify what is NOT working for you... please add more details.

You should also read about HTTP adapters.

  • Training module
  • Information Center (scroll down to invokeHttp)
  • Sample project

More:

  • IBM Worklight - Sending HTTP POST request from the client side
  • how to use plain text in adapter worklight

Since your question is very dull on details,
The below simple POST example is based on this POST method example from W3C Schools.

Adapter XML:

<?xml version="1.0" encoding="UTF-8"?>

<wl:adapter name="PostExample"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.worklight.com/integration"
    xmlns:http="http://www.worklight.com/integration/http">

    <displayName>PostExample</displayName>
    <description>PostExample</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>www.w3schools.com</domain>
            <port>80</port> 
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
    </connectivity>

    <procedure name="sendParams"/>
</wl:adapter>

Adapter implementation:

function sendParams() {
    path = "tags/demo_form_method_post.asp";

    var input = {
        method : 'post',
        path: path,
        parameters: {fname: 'idan', lname: 'adar' } 
    };

    return WL.Server.invokeHttp(input);
}


来源:https://stackoverflow.com/questions/21014983/ibm-worklight-6-1-how-to-send-post-values-in-adapter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!