• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check if webservice is up using axis stub/proxy

 
Basheer Ahmed
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using axis 1.2.1.
There is a webservice I am supposed to consume as a client.
My problem is i need to distinguish between connectivity problems (such as connection refused, time out, etc )and exception thrown by the Web service itself.
This is because I need to retry the webservice call in case it is a connectivity problem and in case it is an exception thrown by the web service, I need to handle it differently (throw out the exception).

Is there any API/method I can use to distinguish connection exceptions?


I have the following piece of code :
Echo_2_0Stub e = null;
try
{
WirelessCSIServiceLocator proxy = new WirelessCSIServiceLocator();
e = (Echo_2_0Stub) proxy.getEcho_2_0_HTTPPort(new URL(
"http://localhost:8080/axis/services/Echo_2_0_HTTPPort"));

EchoRequestInfo er = new EchoRequestInfo();
er.setData("SAMIR");

EchoResponseInfo eresp = e.echo(er);

Call c = e._getCall();
System.out.println("Req is " + c.getMessageContext().getRequestMessage().getSOAPPartAsString());


System.out.println("ERe" + eresp.getData());
System.out.println("ERe" + eresp.getResponse().getCode());
System.out.println("ERe" + eresp.getResponse().getDescription());


}
catch(Exception ex)
{
if(ex instanceof AxisFault)
System.out.println("hai fault axis ka");

Call c = e._getCall();
System.out.println("Req is " + c.getMessageContext().getRequestMessage().getSOAPPartAsString());

if(c.getMessageContext().getResponseMessage()!=null)
{
System.out.println("Req is " + c.getMessageContext().getResponseMessage().getSOAPPartAsString());
}
throw ex;
}
}


Now, is there any way I can check if the service is up before calling EchoResponseInfo eresp = e.echo(er); ?
Or, is there any particular exception/class of exception I can catch, so that I can detect the connection problems?

Any help will be highly appreciated.

Thanks.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is i need to distinguish between connectivity problems (such as connection refused, time out, etc )and exception thrown by the Web service itself.


When there is a "connectivity" problem and the application makes a call on the web service, what happens? What does the web service return?

In regards to exceptions thrown by the web service, what types of exceptions are thrown? What makes these any different than what is returned when there are "connectivity" problems?


 
Basheer Ahmed
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
By connectivity problems, I mean exception like Connection refused, connect timed out,page not found etc.
Whereas the web service itself throws an exception like XYZAplicationException (normally an XYZAplicationException will mean that the request has reached the service and the service has returned an exception in the response).
Could you please advice?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When there is a connectivity problem and the application makes a call on the web service, what happens? What does the web service call return?

Or, in other words, when the application makes a call on the web service and there is a connectivity problem, what happens? What does the web service call return?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!