I'm using eclipse to run a web service written in Java EE. So the service is launched on the local network (192.168.1.1 something like that).
My Android device, connected to the computer, is connected to the WiFi. My question is : is it possible to access the web service from my Android device without publishing the service on a server ? (I cannot access it via http:// 192.168.1.1:8080/myWebService/... Because i'm not n the same network)
I've tried to use the computer network while my device is connected to it but it's seems not to be possible with Windows 7.
As i mentioned in the comments, you have to use the IP of the computer which has the server.
I too had the same problem.If u want to access localhost from your device,here is a good tutorial:
http://www.mobitechie.com/android-2/how-to-access-localhost-on-android-over-wifi/
Related
When i run my project on Emulator than localhost servery is working but when run on real Android phone than localhost server not found. So how can i access my localhost server from my real Android Device. I use XAMP server.
You cannot access localhost from your mobile device because the server is limited to your system only. In order to test the application you have to run the application on emulator so that it could find the server. Although there is a way...if you are creating a whole server that is backend and you have a network to which your mobile and system is connected then you can set your server to listen to a port on that network. I used NodeJs to accomplish that. You can search some tutorials for using NodeJs through which you can access you xampp server. You can also try AdonisJs which is a framework for NodeJs for a better approach. But keep in mind that you need a common network through which your system and your mobile device is connected. It is a bit complicated method but yes that can work. Accessing localhost directly from system to your mobile device is not possible..if you want to avoid learning NodeJs then you'll have to keep using emulator for the testing but learning something new is always amazing. So i would suggest you to learn NodeJs . Anyways you can avoid all the trouble and keep testing your application using your emulator. I hope this answer will help you :)
You should have told which ip you used running on emulator.
Your client on the android device should use the ip of the computer where your server is running on.
Android device and server computer in same WLAN.
If your computer and mobile are connected through same internet line then you can use ip of your computer instead of localhost can do the work.
You cannot access the local host server from a different node eventhough both nodes are connected to same network only way is that change the ip configuration of server to 0.0.0.0: so that you can access the server from any node just by typing the ip of the server followed by port no...
i have in my laptop in virtualbox a UbuntuServer with a webservice at ip: 192.168.1.46, and webservice, ServerName is api.webservice, so from my laptop if i try in the browser api.webservice it works well!.
Now the problem, from the android device not work, the webservice,laptop and device are connect in the same network, from the device if i try in the browser 192.168.1.46, it tell me it works, but if i try api.webservice not work..
there are any solution?
Probably this is a problem with name resolution.
Your laptap (Windows?) is able to resolve "api.webservice", but your Android device not.
It highly depends on your infrastructure (WLAN-Router, DHCP-Server) how to solve this problem. You could perhaps provision your WLAN-Router/DHCP-Server to permanently bind api.webservice to the IP address of your Ubuntu box, so Android device can make a NS-lookup.
I suppose your Android app will connect a real Internet server in future. In this case, I wouldn't bother connecting the webservice by IP-address for test purposes.
When your app is published and used outside your local network, name resolution will work when connecting to a internet server registered in "official" DNS.
I have made an asp web service and I am accessing it from my android application through ksoap2 library. I have successfully accessed the service from emulator by 10.0.2.2:9000/Service1.asmx.
Now I am trying to access it from my android device but I am not able to access it.
I have already hosted the service on IIS and now I can access it from emulator by 192.168.xx.xxx/Service1.asmx.
The problem is still the same Can't see any result in my android app on device that is connected to the same LAN through WIFI, although I can see my web service through mobile browser now. In addition to that I have edited the web.config file to allow all systems on LAN to invoke my web service methods.
I just checked the error. Error toast is showing java io.IOException on device still runs without any error on emulator
I would suggest to check whether 192.168.xx.xxx/Service1.asmx. is reachable via android mobile browser. I doubt that your device could be in some other ip group.
I need to send an image file from the mobile to the server(where the server will save it to the hard disk). I have wrote both the android mobile part and the server side. I need to test the code before deploying to the server. Will the code work if I connect the mobile to the WI-Fi network through which I can have a LAN connection to the system? Is there any way I can test the code with out using a WI-Fi connection(ie Connecting phone to the system via the usb cable and then forming a LAN or something)? Please voice your valuable opinion in these stuff.
When I was testing my server-side I didn't find any other way rather than connecting via wifi, this way it was working just fine (in your code you need to use ipv4, not localhost, just as reminder). I'm not good with network stuff, but I don't think it's possible using usb to create some kind of LAN.
Have u tried from emulator? How to connect to my http://localhost web server from Android Emulator in Eclipse
I am using Android 2.1 tablet. I have created simple application which access my own webservice. It works well in emulator. But it fails on android device. I am getting timeout exception. I have internet permission and timeout permission as mentioned is few forum message. I have disabled firewall for my network. Though I couldn't ping it from Terminal emulator to check the network availability.
Also I tried access the webservice base url via browser in android device. It doesn't work. I have webservice running on port 9080 in a laptop which is connected to same wifi network as android device.
I am absolute clueless. Any help would be highly appreciated.
If the emulator was running on the same machine as the Web service, then perhaps your Web service is only accepting connections from localhost.