Accessing ASP.NET web service from android - android

I have created a basic web service and I need to access it from android but somehow the web service is only accessible on my local machine, with a local URL like http://localhost:4012/MainWebService.asmx but outside my machine when I try something like 187.120.36.4:4012/MainWebService.asmx the 187.120.36.4 being the IP of my machine hosting the asp.net web service it doesn't go through, all my googling efforts have not paid off so far. So any help will be highly appreciated guys and thanks in advance.

First you need IIS Server. This is how to enable it on W10.
Next you need to configure you ASP project to run on the IIS server.
Now you should be able to access your webservice on 187.120.36.4:4012/MainWebService.asmx.
BTW. That looks like your external IP. Are you sure it is correct? I would suspect something like 192.168.x.xxx

If your machine is connected to a router then you need enable port forwarding on your router to your local machine and then run your web service in your local machine.
After you have it set up your connect url will be http://<your public ip address>:port number where public ip address is your router's external ip address.

Related

With localhost running on my desktop right now,can i view it on my android phone(samsung/lg etc)

i have an app(ruby on rails) running great on my desktop(localhost) which can recognize a request from a browser/mobile phone.Can i check it on my mobile phone too,without using android emulator.Just by hitting my ip will help me out????
rails s is by default binding to all interfaces on your desktop.
So if you know the IP address of your desktop (look it up in ifconfig) you can simply use that IP to access the Rails application.
eg: http://192.168.0.100:3000.
You then inspect the user-agent to find out it's a mobile phone or not.
The rails server can be started with the b flag which specifies the IP address you want to use:
rails s -b 0.0.0.0
deploy your app to heroku or AWS and use git to maintain your app code...Then you can connect to your phone using internet

Client Server Programming In Unity using JavaScript

I'm new to Network programming in Unity3D and basically I would like to make a connection between two android devices, through WiFi using the Client Server Model. And I have some questions.. such as
How it is possible to make a server with a specific IP Address?
How can I make a client, who will connect to that server?
How can I transfer messages between client(s) and server?
Any help would be appreciated..
.......
I have write this simple code...
function OnGUI()
{
if(GUILayout.Button(" Initlized server"))
{
Network.InitializeServer(32,25001,false);
Debug.Log("Server has been Initlized");
}
if(GUILayout.Button("connect to server"))
{
Network.Connect("127.0.0.1",25001);
}
}
function OnConnectedToServer() {
Debug.Log("Connected to server");
// Send local player name to server ...
}
I have write this simple code but OnConnectedToServer doesnot give me any responce...
How it is possible to make a server with a specific IP Address?
For the IP address part, you will need a static IP. If you are behind a router, that means you will have to first ensure your ISP gives you a static IP. If they don't, you should try a service such as FreeDNS, which will route your dynamic IP to a web address. You will then need to port forward the specific ports to the server, which should have a static local IP for easy port forwarding.
As for the code itself, I would highly recommend you take a look at THIS website. It has great video tutorials on making a client-server game using Unity's built in networking.
http://www.gamertogamedeveloper.com/
As for your code, you don't state how you run that code. You SHOULD NOT have the client and server being run in the SAME instance. What you need to do to test this is run the Server inside the Unity3d debugger then build the client and run it as a standalone app.
Raknet seems interesting,
have a look here:
RakNet
unity-Raknet

SmartFoxServer unable to connect to server

I am working in android chat application.
I used SmartFox server. I am using 10.0.2.2 as server IP address and 9933 as Port.
Whenever i run this application using emulator then works fine but when i run this application in my real device then connection does not performed correctly. I think this is unable to find out IP 10.0.2.2.
I changed this IP address to 192.168.1.9 which is IP address of my system in LAN on which SmartFox server is installed.
Please suggest me what mistake i have done.
Thank you in advance.
I resolved my problem myself. I created one entry in confi/server.xml file of server.
like this:-
<serverSettings>
<socketAddresses>
<socket address="192.168.1.9" port="22" type="TCP"/>
<socket address="192.168.1.9" port="22" type="UDP"/>
</serverSettings>
</socketAddresses>
or you may add this entry using admin module of Smartfox server. This task can be done using Server configuration part.

How do you access a local port 8080 url from an android http get

I have a restful web service located on a local tomcat instance.
I'm trying to access the url via a get in my application but am getting the error: host is unresolved
I try to access this url from my android emulator browser to confirm the connection there and am unable to get to it their either. An alert comes up on the screen that says: "an sd card is required to download 125562.bin"
I am not using localhost in my url but something that looks like:
http://192.168.1.2:8080/service/0/12345
It returns straight json
Does anyone know why I can't access this in the android emulator? I can successfully hit this same address from my computer browser as well as iPhone and it brings back json.
Does android handle other ports differently than standard port 80? Is the problem this url doesn't have an extension?
The Android-Emulator has a virtual router, which cut's the Emulators network from the host-computers network.
However, this router is part of the network, too and enables you to access servers running on the local machine by using the IP 10.0.2.2.
So you would use:
http://10.0.2.2:8080/service/0/12345
You need to use 10.0.2.2 to emulate your local machine's 'localhost'.
See Emulator Networking

Access to asp.net web service

I wrote a little WS on asp.net, I can open it printing something like
http://46.146.170.225/RouteGen/Service.asmx
in address bar. It's all right, WS works.
But if I print the same address in a browser on the other computer, the page isn't available. How to get access to my web server from other PC? (I need from Android device, but I think it's no difference)
If you started the Web-Service from within Visual Studio then without changing the starup-settings of your project - it's not possible, because VS only starts a local debug web-server that doesn't allow calls from other hosts than localhost.
To allow external IPs to access your web-server, you have to set up the IIS and run your web-service inside it. A firewall could block incoming requests to the IIS but I ran such a service last winter and didn't have to change firewall-settings.
Verify that the website, in IIS, is bound to a public-facing IP address. Right click on your website in IIS, and go to the bindings setting. Then, check the host field. It should have an IP address or domain name that is available publicly.
Verify that your firewall has Port 80 open for incoming traffic

Categories

Resources