Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check if web service is running

 
Maheshwari Kirthi
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20190
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20190
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20190
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20190
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
Maheshwari Kirthi
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 577
Java Notepad Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maheshwari Kirthi
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use WebClient class to hit wsdl url and capture the status of the response.


 
Sharmilily Sha
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
Eclipse IDE Hibernate Java
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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


 
Sharmilily Sha
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic