Topic
  • 4 replies
  • Latest Post - ‏2012-11-28T03:41:22Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic Externally invoking a Worklight HTTP adapter using an HTTP POST

‏2012-11-21T19:05:15Z |
Hello,

Is it possible to invoke a Worklight HTTP adapter externally using an HTTP Post request? As far as I know, I can only invoke an adapter externally using an HTTP Get while appending the adapter function's parameters to the URL. I have a large dynamic payload which needs to be sent and encoding it as a URL parameter doesn't seem feasible.

Any thoughts?
Regards,

Costa
  • AntonAleksandrov
    AntonAleksandrov
    55 Posts

    Re: Externally invoking a Worklight HTTP adapter using an HTTP POST

    ‏2012-11-26T08:14:56Z  
    Hello,

    Yes, you can invoke adapter procedure externally by calling http://server:port/contextpath/invoke API.
    With either POST or GET parameters:
    adapter=adapter-name&procedure=procedure-name&parameters=1,2,3,4

    Depending on WL version you have you might need to specify securityTest="wl_unprotected" on adapter procedure declaration (XML file).
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Externally invoking a Worklight HTTP adapter using an HTTP POST

    ‏2012-11-26T08:32:54Z  
    Hello,

    Yes, you can invoke adapter procedure externally by calling http://server:port/contextpath/invoke API.
    With either POST or GET parameters:
    adapter=adapter-name&procedure=procedure-name&parameters=1,2,3,4

    Depending on WL version you have you might need to specify securityTest="wl_unprotected" on adapter procedure declaration (XML file).
    @AntonAleksandrov-->

    This is my simple adapter can u frame the link. so it will be easy for understand. this is my login function. i wrote service for this. now i want to call this adapter external with passing paramter.

    domain : localhost
    port : 8080
    adaptername:student

    function login(studenid,pass){

    var input = {
    method : 'post',
    returnedContentType : 'json',
    path : "University/studentlogin",
    parameters : {
    studenid:studenid,
    pass:pass
    }
    };
    return WL.Server.invokeHttp(input);
    }
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Externally invoking a Worklight HTTP adapter using an HTTP POST

    ‏2012-11-27T15:43:18Z  
    @AntonAleksandrov-->

    This is my simple adapter can u frame the link. so it will be easy for understand. this is my login function. i wrote service for this. now i want to call this adapter external with passing paramter.

    domain : localhost
    port : 8080
    adaptername:student

    function login(studenid,pass){

    var input = {
    method : 'post',
    returnedContentType : 'json',
    path : "University/studentlogin",
    parameters : {
    studenid:studenid,
    pass:pass
    }
    };
    return WL.Server.invokeHttp(input);
    }
    I believe the link would be something like:

    
    http:
    //localhost:8080/invoke?adapter=student&procedure=login&parameters=["myId", "myPassword"]
    


    for GET.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Externally invoking a Worklight HTTP adapter using an HTTP POST

    ‏2012-11-28T03:41:22Z  
    I believe the link would be something like:

    <pre class="jive-pre"> http: //localhost:8080/invoke?adapter=student&procedure=login&parameters=["myId", "myPassword"] </pre>

    for GET.
    for Method : Post