My question is How to create a Web-service on android device & host it on the mobile. Please don't mis-understood it, I don't want to access the already created webservice deployed on the server, I want to create a webservice that returns json/xml & host it on mobile. I'm totally new to android development but I have programming experience.
Please check this link: RESTful Web Services Implementations in Mobile Devices
It says its doable for java based mobile so I think it can be done for android too.
Thanks.
There is one problem with your setup and mobile devices: mobile networks (wifi and 3g) mostly use NAT, which prevents inbound connections. This makes mobile devices inaccessible from the internet (inbound) while they can still initiate outbound connections. For this reason mobile devices mostly do not host servers.
What you can do is make an Android service which pings a server ( a web-server) every 30 minutes or so simply send a bit from client to server and back to check the availability of request from another phone. This way you can upload media files to server and download them to your another device.
I am trying to solve the same problem and I am leaning towards https://github.com/NanoHttpd/nanohttpd.
It is a tiny webserver without any REST or MVC functionality, thus you would have to write it yourself (MVC, content negotiation, etc).