Publish WebService for public access - java

So, i have some experience developing Java WebServices.
The problem is, all i do is deploy them to localhost.
My question is:
How can we deploy a WebService to a server other than localhost?
How can i search the web and find the WSDL description for my WebService so that i, or anybody else around the world, can call its services?
If i have it in localhost, nobody else but me on my computer can acess it right?...
Thank you for your time

I don't think you'd want to make an application running in your development environment accessible to anybody else around the world for a variety of reasons. Others on your local network could access your local host via its network hostname, but this isn't users around the world.
Let's discuss your two questions individually:
How can we deploy a WebService to a server other than localhost?
You'll want to establish a server environment that is available (on) as much as possible. If you want to keep using Apache Tomcat, you could sign up with a variety of service providers that host Apache Tomcat applications - there are many who offer tiered pricing based on number and size of pre-configured virtual servers (CPU, memory, disk space, and/or monthly data transfer of the application). You could even sign up with a cloud service provider such as Google Cloud, Amazon Web Services, or Microsoft Azure. All provide the tools to build, provision, and manage virtual server(s) which you would then deploy Tomcat and web service application into. Here's a detailed tutorial on setting up a Tomcat virtual server on Azure. You'd then need to manage those server(s), watch them to see how much they're utilized (which will impact how much they cost you per month, by the way).
If server management isn't what you're looking for - you could also explore "serverless" options such as Google AppEngine or AWS Elastic Beanstalk. In this model, you just upload your WAR file and the hosting service manages things like how many servers are needed to handle all the application SOAP requests your users around the world are making. You'll need to read the specifications for each, as you technically aren't providing Tomcat itself - in Google's example, you're actually running in their own proprietary container, so your app may need some changes depending on what it does.
Depending on what hosting or cloud service provider you select, your "how to deploy" steps vary wildly. On the bright side, all offer tutorials on how to specifically deploy applications into them "their way."
How can i search the web and find the WSDL description for my WebService so that i, or anybody else around the world, can call its services?
Once you've settled on a hosting or cloud services provider and have deployed your application, you'll have a URL to reach it, but you'll need to work on getting the word out. There are some open specifications on (SOAP) web service discovery, but more than likely that's not what you're really looking for. You could also submit your WSDL URL to an online API directory such as ProgrammableWeb or Public APIs.
The simplest way to do-it-yourself would be to run a web site that links to the WSDL, then use search engine optimization techniques to list the site on search engines and make it (and the WSDL it links to) relevant to web searches.
Getting fancier, you can treat your web service as a product via an API Management system. At a high level, this works by hiding the real URL to your web service on its server(s) and instead direct clients to a small website for developers where you document, market, facilitate discovery of your service as well as offer a sign up to use it (so you can track and manage who around the world is using your web service). Clients then consume the web service via separate URL behind what's called an API Gateway. You could charge for access or offer it for free but limit the amount of concurrent requests a client can make - after all, you're likely paying your hosting provider for utilization. Some of the cloud service providers Amazon, Azure, standalone API management vendors such as Apigee, Mashery, and many others.

Related

Deploying a Java web application to Amazon

I am sure this question has been asked and answered before multiple times. But unfortunately, I am still not clear. Here is my issue.
I have a JSP, Servlet application which uses MySQL as the database. I have built the WAR file as well. Now I am in need of deploying this so it can be accessed online by anyone.
I looked into lot of areas including normal web hosting. However even though the services like DailyReazor are highly secured, they provide little for MySQL, around 250 MB for the package I selected.
Now I am looking into Amazon AWS. In AWS I am expecting to deploy my aplication and make it available online.The MySQL server should not contain limits like 250MB.
But I have never ever used this service AWS before. By reading various posts, I know that Elastic Beanstalk is the easiest way to go, but still not convinced about how to deploy it properly with database access and all. And in the other hand, will they give me a web address like "www.example.com" or will they simply provide an IP address?? I am also familiar with tomcat so I need to use it.
We will not upload files (images etc) at the moment, so I believe we can manage with around 20$ per month?
I really appreciate if someone can provide a clear guidance on deploying java web applications in Amazon, with the requirements I mentioned about MySQL, Global access and so on.
Amazon RDS for MySQL is a Database-as-a-service offerring from AWS. It is scaleable up to 3TB, and has scaleable IO as well. Of course it also depends on how much you prepared to pay. they manage the DB for you (backup etc). You get a URL to connect, credentials and you are set to go.
Amazon Elastic Beanstalk uses Tomcat. So you should be familiar with that. You upload your WAR file and specify what EC2 flavor you want (CPU/MEM etc). They launch a VM that is configured with Jva and Tomcat and deploy the WAR for you. You get an IP address.
Amazon Route 53 is the DNS service, where you can assign the IP address to your domain (assuming you have one)

Developing Apps for iOS, Android and the Desktop

We have an existing distributed application used by a small company to manage their customers.
The server side component is deployed in the cloud as a simple Java app that manages a connection to a MySQL database.
The client side is implemented as a Java Swing application deployed using JNLP and communicates with the server side using RMI.
This has worked quite well for us so far, but recently we've been looking at how our customers could access the application from mobile devices, tablets (both iOS and Android) as well as from the desktop.
At the minute I'm thinking we should be looking into developing RESTful web services on the server side to manage access to the MySQL database. On the client side, we could use Googles GWT to provide a quick and easy solution for accessing the services from all platforms. Going forward we could implement native iOS / Android apps to access the web services.
Am I am the right track here? Does anyone have any better approaches? Does anyone have any recommendations as to what tools I should be looking at?
The key thing I am interested in is being able to access the server side from any platform. I really don't want to have to implement separate server side implementations for each
Sounds like you are on the right track with the RESTFul web services. If you go this route, you should be covered for the backend. As long as your frontend can do http requests and handle JSON data you will be fine.
Going forward we could implement native iOS / Android apps to access the web services.
It is possible to design a mobile app for deployment on both android and iOS, this could save time on the development effort. To do that you could use, for example PhoneGap, which creates an abstraction layer over the phone hardware, along with something like jQuery Mobile, in which the UI is developed in HTML5 and javascript, and the same code is deployed via PhoneGap on both devices.
PhoneGap: http://phonegap.com/
jQuery Mobile: http://jquerymobile.com/
if there is some other option that lets you deploy the same frontend on android, iOS, AND the desktop, i would go with that, so that you only have one code base for the frontend.
I think your solution (GWT/HTML5) client talking to a server-side "business" layer is a good multi-client solution. RESTful web services are unneccesary in the context of what you have described since the GWT implmentation would take care of the comms between client and server:
GWT client <---> Server (GWT) <---> Database
If you are using a different client implementation (such as iOS), then RESTful services will be very handy indeed (and you wouldn't use GWT):
iOS client <---> Server (RESTful endpoints) <---> Database
HTML5 is becoming provides a decent compromise between broad applicability (many clients) and rich client features. I have seen an article in the past about using PhoneGap and GWT together which sounded like a good strategy for working with GWT (which I like) and gaining access to device-dependent capabilities. All whilst working in an environment where you can (Java-)debug even client code (incredibly useful GWT feature).

Running a java application on a remote server

I want to run a standalone java application on a remote server. It would not be accessible to clients, but would do background calculations and interact with a database and Secure Socket connection to a third party site. It would also interact with a php site.
Do I have to deploy this with JSP, or can I write a standalone application? If so, how would I deploy a standalone java application (jar file) on a remote server? I understand that I must have them install a jvm on the server (not a problem) but then how would I deploy it (if possible). Would I start it with a command line?
I know I have much to learn, but I am not sure how I would access the command line on a remote server. Through the cPanel?
Thanks.
First of all, you'll want to set up some firewall rules to allow access to that server. I'm hoping that you don't expose that server naked to the Internet.
If all you need is database access exposed on the Internet, I don't see why it can't be a secured web app deployed on a servlet/JSP engine and accessed via a web server. You can leverage basic auth for security, JDBC access to the database from the server, and servlets as controllers to accept requests in a nice REST API.
It'll save you the complications of sockets and inventing your own protocol (use HTTP), starting and stopping the application (now it's just a web server/servlet engine), and deployment (send a WAR file).
Does it really must be a 'standalone' application? I think that in your case the best match would be to use Spring container to load your application within some server (tomcat?) and expose services via standard controllers - with Spring you only have to add some annotations on services methods actually.
Then, your php site can interact with these controllers using for example ajax requests.
If your application is written already, you can easily transform it to run within Spring container. It's very non-invasive and promotes usage of POJOs.

What is the difference between PaaS and app server hosting?

In terms of deploying a java web app on the internet, what is the difference between sites that offer app server hosting such as Tomcat, Jboss and Glassfish, and sites that offer platform as a service such as Google app engine, Heroku and Amazon EC2?
Difficult question, since PaaS is often misused term.
But I'll try: PaaS usually involves (another) layer of abstraction (you usually don't really know on which server exactly your app is running). Plus your application may or may not share the hardware with one or many other tenants.
Traditionally providers of app server hosting just used N (like 1000) customers per server and calculated that way. GAE etc. try to optimize (distribute the load more cleverly) this and usually charge you on what you actually use.
IMHO: In theory you could use more resources on a app server than you actually pay. But since they usually over-sell, you'll find it hard to get what you pay for. In theory, with pay-what-you-use PaaS offerings you get should what you pay for. /IMHO

How/where to deploy my webapp on my own server?

I have a built small web app using Java/J2ee. I want to host it myself in my own servers (I have none now). I have already downloaded Ubuntu Server OS. I prefer to host my app on my own servers (preferably using Linux, Apache and MySQL) rather than google app engine or any other hosting service?
Can some one guide me to look for server
hardware?
Where should I buy them?
What sort of things I should look
for in webserver hardware?
Which is cheaper, hosting on 3rd party
servers or our own servers?
Can you provide some links where I can learn about creating webapps and hosting on our own servers?
The software you list can run on virtually any computer hardware, your requirements and intended use/target audience would be the starting point to assess what kind of hardware you need for scalability.
If it's for learning purposes or development just run it on your own pc or get the cheapest hosting account you can find.
Additional info needed to properly suggest anything.
If you want to host app for testing/trial purposes, go for for google app engine or 3rd party cheap shared hosting. If you are looking for reliable hosting or dedicated server, it is better to go for grid hosting providers such as media temple.
I would not suggest hosting app on your own servers. Running own servers is overhead and comes along with its own set of maintenance problems. Instead going for reliable hosting provider is a smart move.
Some of web hosting providers you can look for..
MediaTemple ( Highly recommended )
GoDaddy
Blue Host
DreamHost
You might want to see if you can get hold of a copy of Professional Apache Tomcat 6 , which gives good advice on administering Apache (both web-server, and tomcat).

Categories