1

I want to develop a Java based Webservice on my laptop. This webservice will take one input parameter, query my SQL Server database and will fetch information and will return it back.

I know, I do not need a webservice here. But, right now, I am just testing my android application which will call this webservice and will show return data on my device.

So, I have developed a java program which connects my SQL Server Database (which is present on my laptop) and returns a value against the parameter passed. I have made it a webservice by creating endpoints and publishing it from another class.

For reference, something like answer on this thread

So, when I run it from my Eclipse, I can go to a browser and run my webservice, pass parameter and get result.

But, once I close my eclipse, its no more accessible. I am new to this and after studying I am guessing that I will need IIS to host it on my laptop.

I want to ask, whether it is possible to run/publish it locally on my laptop as a background process so that I can test my android app by calling the same?

Future scope -

I am going to deploy this webservice in my company which will connect my database. Both webservice and sql server will be on same machine. I am going to call this webservice remotely over internet from my android device to show the results.

I guess, I will need IIS in future right? Is there any other way to fulfill this requirement? Please provide some ideas.

Community
  • 1
  • 1
Techidiot
  • 1,921
  • 1
  • 15
  • 28

2 Answers2

1

If, within Eclipse, you can get your web application deployed so that it is accessible via a browser, then you definately can do it without eclipse.

Eclipse uses plugins like Tomcat or Glassfish to run your webserver. These programs are available outside of Eclipse as standalone services. You can install these and run them as background processes at the command line.

Just figure out which one you are using in eclipse (or which one you want to use) and look for a standalone copy on the web.

Here's Tomcat, btw.

Don Subert
  • 2,636
  • 4
  • 27
  • 37
  • I went through some threads which shows the webservice deployment using ant. My laptop doesn't have ant application but still the webservice works. I am having Tomcat installed on my machine. I tried installing ant as well. But the documentation says, I will need a build.xml file to use it but unfortunately, my webservice is a set of 2 java classes. One which has a method and the second which creates endpoint and deploys it. How should I go ahead with this? – Techidiot Feb 16 '15 at 09:44
  • Ok. I am half done now. I have generated build.xml for my java project. Now, I can use ant Publish to publish my webservice. But, I want this to run in background. Any ideas? Tried creating a bat file and adding the command to it. Didnt worked. – Techidiot Feb 16 '15 at 11:03
  • Regarding your ANT issue. You should start a new topic for that. It is unrelated. – Don Subert Feb 17 '15 at 02:05
  • Thanks. But I have managed to solve it. Updated the answer. Thanks for your help. – Techidiot Feb 17 '15 at 06:47
1

I am done with this.

What I did is, I went to Eclipse, selected my Project-> Right Click -> Export -> Under General -> Ant Buildfiles

This created, Build.xml in my Project directory.

I deleted all the class files and recompiled them using ant command.

In my case, target name was build-project which compiles all the java files.

So, I did ant build-project

Note - This was done as Eclipse was using different JDK version.

Now, I called my publish class to publish my webservice with

ant publish

This was half done as this was running in interactive mode.

Then I created a bat file with following command -

"path_for_ant_bin_directory\ant" -buildfile "path_to_build_file\build.xml" publish

This was opening up the command box. So, I created a vb script to run the bat file in background

Set oShell = CreateObject ("Wscript.Shell") Dim strArgs strArgs = "cmd /c path_to_bat_file\my_bat.bat" oShell.Run strArgs, 0, false

And, now it nicely runs in background and I can access my webservice.

Hope it helps someone with similar requirement.

Techidiot
  • 1,921
  • 1
  • 15
  • 28