2

I am trying to establish a connection between my client app running on my android mobile and a server running on my windows 7 PC.

I am new to android and so while looking for some client server tutorial, got the below 2 links.

http://www.compiletimeerror.com/2013/09/creating-java-web-service-using-axis-2.html

http://www.compiletimeerror.com/2013/09/accessing-web-service-from-android.html

Here, server is developed on java and published using axis2 webservice. I followed the tutorial and could develop the similar client and server which runs fine on the emulator. But if I try to access the same using my android mobile it is not working. My mobile is unable to speak to the localhost on my PC.

What I am doing here is,

1. Connected both my PC and mobile to same WIFI network.
2. Connected the mobile to PC using USB.
3. Started the Server on Tomcat
4. Running the Client Project from eclipse and selecting my mobile as target.

Below is my published webservice URL which I am calling from client code,

http://192.168.0.3:8080/MyWebService/services/WebService?wsdl

Here 192.168.0.3 is my PC IP

Please let me know what am I doing wrong here?

user001
  • 991
  • 6
  • 16
  • 34
  • What is not working? You get any error in Logcat? Dont you have any firewall rule blocking port 8080? – Salem Jul 19 '14 at 12:28
  • It says unable to connect to 192.168.0.3. Do I need to publish webservice on Internet? – user001 Jul 19 '14 at 12:31
  • @user001 I think you should publish on server. But if someone knows then elaborate. how could it be possible to access the webservice which is not deployed on server. When you are running the application on emulator it knows you localhost IP since tomcat server is running on the same. – vermaraj Jul 19 '14 at 12:36

3 Answers3

3

Windows 7 might block port 8080. You could test that your port is open from another pc using

telnet 192.168.0.3 8080

or from android using this code.

If 8080 is blocked, then you may want to open it using these steps:

  1. Open Windows Firewall by clicking the Start button Picture of the Start button, and then clicking Control Panel. In the search box, type firewall, and then click Windows Firewall.
  2. In the left pane, click Advanced settings. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
  3. In the Windows Firewall with Advanced Security dialog box, in the left pane, click Inbound Rules, and then, in the right pane, click New Rule.
  4. Follow the instructions in the New Inbound Rule wizard.

Note: You must be sure beforehand that your android device is connected to the same local area network or wifi.

Community
  • 1
  • 1
ThomasEdwin
  • 2,035
  • 1
  • 24
  • 36
  • Hi Thomas, yes telnet command says that port 8080 is blocked. Then I tried all the steps given by you but even after creating a new rule in Inbound rule wizard, telnet is giving me the same error. (unable to access IP with Port 8080) – user001 Jul 20 '14 at 05:03
  • Hi @user001. Have you tried accessing port 8080 from the server pc using 192.168.0.3 ? – ThomasEdwin Jul 20 '14 at 06:12
  • Hi Thomas, I could see now that my PC is able to ping my mobile and also If I run the server code on mobile and Client code on PC then, my mobile is able to read the information sent by client(PC). But I need the vice-versa (i.e. mobile as client and PC as server) which is still not working. It says destination unreachable. – user001 Jul 23 '14 at 16:59
  • Perhaps AP isolation in your router? – ThomasEdwin Jul 24 '14 at 04:09
  • Well Thomas, my problem is resolved now. It was w.r.t. firewall. Windows firewall was turned off but even then issue existed. Then IT person changed few settings and it is working now. (not sure what changes were done) I am marking your solution as correct as you pointed me in the right direction. Thanks for your help. – user001 Jul 27 '14 at 10:42
0

Try to access your URL

http://192.168.0.3:8080/MyWebService/services/WebService?wsdl

from your android browser. If you are getting an xml page, then it's not the network problem. If it's network problem, try restarting your local server and changing firewall and router configurations.

You have to provide more information to get a specific answer.

JIthin
  • 1,413
  • 1
  • 13
  • 29
  • Android mobile is not detecting my PC IP itself and so the Android browser also doesn't display the WSDL. Let me know what settings has to be done on firewall and router. – user001 Jul 20 '14 at 05:05
  • For your WiFi router there will be a configuration IP . For most of the vendors it is 192.168.1.1. And all the devices connecting to this network will get an IP of type 192.168.1.xxx. So make sure that you are using the IP of the system for this particular network . – JIthin Jul 20 '14 at 16:57
0

If everything is fine then u should check your Android App. U have to add the following permission for Internet access.

<uses-permission android:name="android.permission.INTERNET"/>
Mehul
  • 2,141
  • 1
  • 15
  • 15