Meaningless Drivel is fun!*
The moose likes Web Services and the fly likes Check if web service  is running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Check if web service  is running" Watch "Check if web service  is running" New topic
Author

Check if web service is running

Maheshwari Kirthi
Greenhorn

Joined: Jan 24, 2011
Posts: 18
I created Java Proxy classes from the WSDL generated from a COBOL copy book.
I have the ProxyPort and the Service classes generated.

How do I check if the WEB Service is up and running on the server?

Thanks,
Kani
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Are you asking because you are the administrator of the server and you want to make sure it is available? Or are you asking because you have written some code which is a client of that web service?
Maheshwari Kirthi
Greenhorn

Joined: Jan 24, 2011
Posts: 18
I have written some code which is the client of the web service, have check if the webservice is running and if it is then render the page accordingly.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

In that case, you don't have to check whether the web service is running. At least, you don't need a separate step specifically for that. Just connect to the service and send your request. If it isn't running, then you will get an exception.
Maheshwari Kirthi
Greenhorn

Joined: Jan 24, 2011
Posts: 18
That's problem I don't get an exception from the web service, and more over if we set a debug on the mainframe side, it actually tries to execute the code.

I access the WS as below:

TestWSPortProxy proxy = new TestWSPortProxy ();
proxy._getDescriptor().setEndpoint("http://110.12.30.45:46379/TestWS");
proxy.getList(comArea);

where TestWSPortProxy is the JAX-WS java proxy generated class and comArea is of type DfhCommarea

so before accessing the WS method getList I want to know if the WS is up and active.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

There's no point in that. Consider this series of events:

1. You check to see if the service is running. It is.

2. The service terminates.

3. You try to use the service.

Anyway in the example you sort of described there, the service was indeed running. Otherwise you couldn't have connected to it. So trying to find out whether it was running would not have been of any use.

I suggest you describe your actual problem and let people comment on that, rather than insisting on a proposed solution and making people help you implement that.
Maheshwari Kirthi
Greenhorn

Joined: Jan 24, 2011
Posts: 18
ok forget the code, all I want to do is serve as a Java Middleware check if the externally hosted WS is up and running.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

So just send it a request, and if it responds then it's running. If this is a legitimate requirement (and as I pointed out already, it isn't a legitimate requirement for clients of the service) then the service will support a "ping" request which you can use.
Maheshwari Kirthi
Greenhorn

Joined: Jan 24, 2011
Posts: 18
Thank you.
Maheshwari Kirthi
Greenhorn

Joined: Jan 24, 2011
Posts: 18
Hi it's me again. I send a request to the webservice just by creating a new instance of the service, but I get the service instance, though I removed the WS from mianframe server.

Thanks in advance.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Kavi,
To just check if your Web Service is working, try invoking the url in soap:address location attribute of WSDL following by ?wsdl.
For example:
<soap:address location="http://localhost:8080/ABCService/ABCPort"/>
In browser, check if http://localhost:8080/ABCService/ABCPort?wsdl is working. This tells you if web service is really up and running. But, to check if it is servicing your requests, you have to send request messages and see.


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Maheshwari Kirthi
Greenhorn

Joined: Jan 24, 2011
Posts: 18
Hi,
Thank you very much for the reply.

Actually our mainframe server had a wrapper program around the actual web service and was setting a return vaue of -1 in the comm area in case of any exception and not throwing the actual exception.
That's why I was little confused about why my WS request was not behaving as expected on the Java end.

Again thanks Naren and also thank you Paul .

Thanks and Regards,
Kani.

Abhinav Taduka
Greenhorn

Joined: Feb 02, 2012
Posts: 6

You can use WebClient class to hit wsdl url and capture the status of the response.


Sharmilily Sha
Greenhorn

Joined: Feb 17, 2012
Posts: 11
Hi
I am writing an application in c# to check if a webservice is running by using webclient class. I want a similar code as yours to check if webservice is alive or not.below is my incomplete code:
namespace ConsoleApplication2
{
class Program
{
public bool checkstatus()
{
WebClient client = new WebClient();
client.set_BaseAddress("http://localhost:33242/Service1.svc?wsdl");
WebResponse response = client. [Method to be used here];

if(response.[Method to be used here]==200)
{
//Web service is up
}
else
{
// Web service is down
}

}


}
}
}

Please respond as soon as possible
Abhinav Taduka
Greenhorn

Joined: Feb 02, 2012
Posts: 6

Hi,

I am not expert in C#. Following code might work.


Sharmilily Sha
Greenhorn

Joined: Feb 17, 2012
Posts: 11
Hey thanks ... that really worked...
I also want to know how to check if there are any connectivity problems while accessing a database through a web service ..........
and adding the credentials to it while checking
That would be of great help
Thanks
 
wood burning stoves
 
subject: Check if web service is running
 
Similar Threads
setting nillable and minOccurs Values in AXIS2 service.xml
calling methods from external web service
How to run Webservice client from wsad
Thread safety of Axis client classes
Issue related to JAX-WS and Maven