Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow exceptions to provide custom SOAP::SOAPFault responses

  • Loading branch information...
commit 5176f14df5aa2bd853f195be6a6471b14751da60 1 parent 3161ac6
Nick Hengeveld authored
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/action_web_service/protocol/soap_protocol.rb
16 lib/action_web_service/protocol/soap_protocol.rb
View
@@ -102,12 +102,16 @@ def encode_response(method_name, return_value, return_type, protocol_options={})
response = SOAP::RPC::SOAPMethodResponse.new(qname, nil)
else
if return_value.is_a?(Exception)
- detail = SOAP::Mapping::SOAPException.new(return_value)
- response = SOAP::SOAPFault.new(
- SOAP::SOAPQName.new('%s:%s' % [SOAP::SOAPNamespaceTag, 'Server']),
- SOAP::SOAPString.new(return_value.to_s),
- SOAP::SOAPString.new(self.class.name),
- marshaler.ruby_to_soap(detail))
+ if return_value.respond_to?(:to_soap_fault)
+ response = return_value.to_soap_fault
+ else
+ detail = SOAP::Mapping::SOAPException.new(return_value)
+ response = SOAP::SOAPFault.new(
+ SOAP::SOAPQName.new('%s:%s' % [SOAP::SOAPNamespaceTag, 'Server']),
+ SOAP::SOAPString.new(return_value.to_s),
+ SOAP::SOAPString.new(self.class.name),
+ marshaler.ruby_to_soap(detail))
+ end
else
if return_type
param_def = [['retval', 'return', marshaler.lookup_type(return_type).mapping]]
Please sign in to comment.
Something went wrong with that request. Please try again.