Soap


#1

Hi quick question, I have a soap server and soap client ruby scripts.

When I try to run the soap client without starting up the up the server
the client program crashes out, as you would expect. But I’d like to
catch that exception and wait 5 min’s before it tries again.

so I have a little bit of code that goes.
begin
Timeout::timeout(900) do #try 3 times before quiting.
not_connected = true
while not_connected == true do
begin
@soap_wrp =
SOAP::RPC::Driver.new(“http://localhost:9001”, “http://fasw111/Submit”)
not_connected = false
puts @soap_wrp
rescue SystemExit
not_connected = true
sleep 300 #sleep for 5 min
end
end
#do some soap stuff

    rescue Timeout::Error
     puts "time out error"
     soap_wrp = -1
  end

But once the SOAP::RPC::Driver.new fails to find the server there seems
to be a complete crashs out of the code.
Does anyone know how I can get around this?

Thanks.
fishman2001.


#2

On 2006-04-03 01:47:03 -0700, fish man removed_email_address@domain.invalid said:

Hi quick question, I have a soap server and soap client ruby scripts.

When I try to run the soap client without starting up the up the server
the client program crashes out, as you would expect. But I’d like to
catch that exception and wait 5 min’s before it tries again.

A couple of thoughts that are non-specific to the SOAP modules:

Try rescuing on Exception instead of SystemExit… If that fixed your
troubles, then you know you’re catching the wrong exception. Another
important thing to do (obviously) is read the information on whatever
is terminating execution.

Aside, your timeout is not going to ensure trying 3 times. It will wait
900 seconds, but depending on how long the connection takes to timeout,
your 300 second sleep will cause more troubles.

What might be better is something like this:

3.times do
begin
@soap_wrp = SOAP::Stuff # fill in your driver here
rescue Exception => e
puts e # for debugging
end
end

exit(-1) unless @soap_wrp # @soap_wrp is nil, we are not connected

rest of code…

This may look just like a shorter solution, but it solves a lot of
potential problems due to eliminating unnecessary complexity.


#3

On 2006-04-04 07:12:04 -0700, Erik H. removed_email_address@domain.invalid said:

3.times do
begin
@soap_wrp = SOAP::Stuff # fill in your driver here
rescue Exception => e
puts e # for debugging
end

There should be a ‘break if @soap_wrp’ right here.


#4

Erik H. wrote:

On 2006-04-04 07:12:04 -0700, Erik H. removed_email_address@domain.invalid said:

3.times do
begin
@soap_wrp = SOAP::Stuff # fill in your driver here
rescue Exception => e
puts e # for debugging
end

There should be a ‘break if @soap_wrp’ right here.

I did this, tried to catch the exception, but it still crashes out.
give the error
Errno::ECONNREFUSED

any ideas?


#5

I know this is a VERY stale thread, but would this Exception actually
catch a Timeout? I ask because I need to do this so our app doesn’t get
hung up if the webservice we are calling tips over. Perhaps (likely)
there is something obvious I have just not seen, but it seems like this
should be fairly trivial to do.

-jay