ActionWebService - how to raise SOAP::FaultError

I’m testing SOAP interoperability between a command line ruby script
and a Ruby on Rails based web service.

I can’t seem to figure out how to get the service to raise an
exception that gets propagated back to the client as a
SOAP::FaultError, complete with fault code and fault string.

Running my client ruby script against an Apache AXIS based Java SOAP
Server or NUSOAP based PHP correctly gives me back an error of the form:

#<SOAP::FaultError: authentication failed>

from which I can then extract

fault code: 1001
fault string: authentication failed

Running against a Rails based Web service no matter what I raise on
the server, it always seems to end up on the client as a
#<RuntimeError: authentication failed>.

Any suggestions?

Here’s the code for my service:

def authenticate(login, password, version)
if (login == ‘khans’)
return [1, ‘Shehryar’, ‘Khan’]
raise ‘authentication failed’

Here’s the code for my client:

require ‘soap/wsdlDriver’

Ruby on Rails URL

factory =“http://localhost:3000/service/

soap = factory.create_rpc_driver
soap_response = soap.authenticate(“khans”,“bollox”,“1.0”)

 puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
 puts "Service.authenticate() succeeded:"
 puts "  id: "+soap_response[0].to_s
 puts "  firstname: "+soap_response[1].to_s
 puts "  lastname: "+soap_response[2].to_s
 puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

rescue => e

 puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
 puts "Service.authenticate() failed:"
 puts "  fault code: "+e.faultcode.to_s
 puts "  fault string: "+e.faultstring.to_s
 puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs