7 years, 1 month ago.

Call a webservice in mbed (webservice Client)

Hi everyone, is there any webservice client code. How i can call a webservice that is made in java with my MBED

Greetings

1 Answer

7 years, 1 month ago.

you can use web sockets to perform this task. What you need to do is to create a mbed client which will create a web socket and it will send the data to the mbed server via websockets. You can display this data on your website using the html5 web sockets/

As your service is in java you can create rpc remote call from your java application to mbed controller.

My suggested solution would be to create web socket on mbed and use this socket to send this data to mbed server. you can use this data then on your application using the html5 websockets. have a look on these links

http://developer.mbed.org/cookbook/Websocket-and-Mbed http://developer.mbed.org/cookbook/Interfacing-with-Java

Hi, i know that the websockets exists, but my question is especifically of how to make the MBED Webservice client, because i have al the webservices developed. Can you explain better your answer?

Greetings

posted by Ney Palma 01 Nov 2014

have a look on this piece of code:

#include "mbed.h"
#include "EthernetInterface.h"
#include "Websocket.h"
 
 
int main() {
    char recv[30];
 
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("IP Address is %s\n\r", eth.getIPAddress());
 
    Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo");
    ws.connect();
 
    while (1) {
        ws.send("WebSocket Hello World over Ethernet");
        wait(1.0);
    }
}
   

what this code is doing is, it first creates the ethernet instance to connect your device with the internet, then it creates the webservice instance to connect to the webserver of mbed site, and then it send the simple string to webserver.

posted by zain aftab 03 Nov 2014