I created a simple webserver, which listens on port 8080 on my Android device. I can reach the service by calling 192.168.1.23:8080 in a browser from a laptop which is in the same network.
Question: How can I call the service by an URL?
AirDroid does this, and it works by calling http://web.airdroid.com.
Any domain name can be pointed towards an IP address by setting its DNS settings. If you own a domain name, you can go into the DNS settings and set up a subdomain (eg test.yourdomain.com) with an "A" record with the IP you want (192.168.1.23). Now, assuming you're connected to the internet (so the PC you're accessing from can access DNS servers), if you go to test.yourdomain.com:8080 in a browser on the same network as the phone, it'll request data from 192.168.1.23.
You can do this locally by editing your HOSTS file. If you put an entry into the HOSTS file of a computer (common file locations are on wikipedia) that looks something like this:
192.168.1.23 test.anydomain.com
If you then visit http://test.anydomain.com:8080 on the computer with a modified file, it will redirect to your phone. You don't need to own the domain to do this - your HOSTS entry will override whatever the actual domain owner has set up.
If you don't own a domain, you can generally register a subdomain from noip.com or other providers which you can set up with an A record to your local IP address.
Note that none of these options will negate the need for the ":8080" to be appended on the domain. The two ways to get around that are to a. serve web data on port 80 from your phone (it may not be possible?) or b. surround the data the phone's serving in an iFrame. Services like noip may (I've not used it in years) have an option to do a "masked redirect" or something similar, which would essentially just do that.
The airdroid example is not quite the same as this. It seems that they serve (from their servers) a web interface which (I assume) fetches data from your phone in the background.
first if you use ur webservice on your local pc then you need a server application that can handle this sort of things you can check out IIS if u r using ASP.net and C# or MVC or any microsoft based services .... if u r using PHP there is many software's that can be installed to run php code like WAMP server
second if u r using IIS you will need probably ksoap link to library which implements webservice based on IIS ... if u r using php then you will need to call it from ur app like this http:// (your ip):(port)/directory name here/yourPHPfile.php
Related
I have just created a Hello World RESTful Java API with IntelliJ IDEA and Spring and I make several requests with http://localhost:8080/function and it works fine and return the JSON data well, but now I want to make request from my android app to get the same JSON data from another network. How to create global API or make my local API global or online?
If it is working on your PC, your next step is to host it somewhere which is reachable from the outside world. If it is still in testing mode, probably what you need to do is port-forwarding from your router, so that your requests to your public IP get forwarded to your PC.
In the long term of course you need to host it somewhere, unless you want to leave your PC running. You can buy a cheap hosting to start with on something like Digital Ocean, or go for the more advanced cloud service providers like Google and AWS.
in your router you have to redirect port 8080 to you network IP and allow port 8080 in your firewall
And use this IP address https://whatismyip.com.br/
You can create your java application in a container and deploy it on one of the cloud providers (AWS, Azure, Google App Engine).
In my project I need to find the public ip address of a machine.
I have implemented that using method mentioned in Finding public ip address using java
I have an api url like 'http://182.14.10.5:8080/test/addVendor' (not exact url) in my project and has been deployed in external tomcat server which has public ip address as 187.15.161.90.
The issue am facing is:
When i tried loading this api url from other devices like mobile or computers belong to some other network, am getting the same ip 182.14.161.90 for every URL hit.
This is where i got confused. Whether the program is written according to that or am i getting wrong output.
According to the search results what I understood is, when I load the particular api url, I should get different ip address based on different machine connected with different network.
But am getting the same public ip (182.14.161.90) of the server where my project is deployed.
Can anyone pls clarify it and help me to fix the issue.
Any suggestions would be appreciated.
Thanks
It sounds to me like you have a Java Web Application deployed via tomcat and want to get a user's IP address.
The question you've linked in your question Finding public ip address using java is specifically for getting the IP address of the machine where the Java Code is running (for example, if you have a desktop application and want to get the IP of the machine that app is running on for some reason)
If you want to get the user's remote IP, it depends on your server configuration
If Tomcat is the ONLY webserver in your environment, and there is nothing in front of it, you can access the Request's remote ip using HttpServletRequest#getRomoteAddr, which will give you the IP address of the socket connection that initiated the Request.
This will work great unless you have a proxy server, like Apache HTTPD or Nginx in front of Tomcat, in which case you'll need to configure your server to send the
X-Forwarded-For header, and get the user's remote IP using HttpServletRequest#getHeader for example, request.getHeader("X-Forwarded-For")
If I've misunderstood your question, please clarify and let me know with a comment.
I am new to JSP and servlets. I configured my eclipse and am now able to run a helloworld jsp program. Now, i want this to be run on a different system.
Following were my queries.
1) Can i enter the IP of my current system where eclipse and tomcat are installed and running and run the application on the computer 2?
2) If question one is not possible, how can i test my application outside local host without purchasing the server.
Please share your knowledge
If I got you right, option number 1 should work.
You currently have a webapplication running on your local machine. So you can enter something like http://localhost:8080/myapp in your browser and see a webpage from your application.
Next step to replace localhost with an ip adress or computer name. So still on the same computer the following should work: http://192.168.123.1:8080/myapp and http://mycomputer:8080/myapp. Of course I just made the ip address and the computer name up and you have the real values.
These two urls should also work from a remote computer that is on the same network. Like the computer of you coworker, or the second computer in your home network.
Possibly the next step would be to deploy your application on a cloud service. But that is a different story worth its own question.
You can put your app in tomcat directory/webapp.
you have to put there .war file of your application.
Then from firewall add inbound rules that on port 8080 incoming request to all connection.
then from at any place from your intranet just type your ip :8080/app.
look here my answer of same query like you.
it is possible in LAN you just need to put the SERVER IP instead of localhost
example: 192.168.1.23:8080/test
if you want to access it in outside via Internet connection
first you should have STATIC IP it is provided by your internet service provider ask them.
and dont forget to off your firewall or add it to exception
I need help with a question that I could not answer yet.
I have the following scenario:
One application Java EE / Flex 4 running on a tomcat, inside my Flex layer I have a iFrame passing a url to an ip of my internal network (http://192.168.1.195:8080/webvisu.htm) which is another application running within an industrial PLC.
When access this app from within my internal network works fine, but when I try to access this iFrame to an external network in my home for example have a timeout error on http://192.168.1.195:8080/webvisu.htm.
I believe this error occurs because the flex client is trying to run this url as I was in a internal network.
Is there any way to run this url from an external network?
Possible solutions:
Some setting on my Tomcat?
A crossdomain.xml file?
I've googled a lot about this problem, but found no solution = (
Sorry for my english I'm using the google translator
192.168.1.* is not a public IP address. The only way you'll be able to access it is if you have your home network connected to the other network over VPN; or if you have a web server set up on your local network which is running on the same IP address.
The use of domain names are supposed to address the problem of accessing IPs directly; but if you're accessing a non-publcly accessible app, you're kind of stuck.
On my current project, for example, the dev server uses an IP Address and the QA server uses a IP address. Neither of these apps are accessible outside the network. I have to connect via VPN to access them.
The production server; however; uses a domain name.
i need to send a request to a website when a user submits their url, i tried using curl but it uses server ip which i dont want i have seen a website that is doing a similar job by using applet, users need to open a popup which contains the applet after they leave it open allow it to run it uses a port and then uses the localhost ip like so 127.0.0.1:64653 to send request and basicly curl by the user ip. i decompiled the applet the website was using and they were using java.net.ServerSocket and some other java code but i do not know anything about java. I would to know how this can be done.
I think you are really confused.
a user does not have a URL.
there is a IP address that
represents the browser end of the
connection to the web server he/she
is connected to (actually, there
could be more than one) but this
does not allow something else to
establish a connection to the
browser. So it is not a URL.
the IP address + port number
that the browser has are transient.
In 2 minutes time, the very same
IP/port could denote a different
user, possibly even on a different
machine.
127.0.0.1 is a "special" IP
address that says "this machine".
It cannot be used for communication
with another machine.
notwithstanding all of the
above, web browsers do not accept
incoming HTTP connections from web
servers or anything else. The HTTP
protocol (which is what the web
works on) distinguishes between the
roles of "client" and "server", and
specifies that a client connects to
a server and not the other way
round. A web browser is always an
HTTP client, by convention and also
for security reasons.
So when you say ...
i need to send a request to a website when a user submits their url
... it simply does not make any sense. Please explain what you are tying to achieve ... not how you are trying to achieve it ... and we might be able to help.