views:

220

answers:

1

I've used wsdl2ruby to generate a client for a web service. When a service method raises one of the exceptions defined in the WSDL I'd like to access the exception object's attributes. From what I can tell the exception object has been marshalled into a SOAP::Mapping::Object that's referenced by the detail attribute of the SOAP::FaultError object that's made available to the RESCUE block.

Although SOAP::Mapping::Object responds to a marshal_load method, that method takes one parameter, dumpobj, which makes me think I'm supposed to provide that object as the method's parameter rather than use the object as the method's receiver.

Can anyone point me to an example of the proper way to unmarshal the exception object?

A: 

looks like the unmarshalling is already done, if you probe into the SOAP::Mapping::Object ...

rescue SOAP::FaultError => ee
  ## InvalidLogin, InvalidLocale, NoPermission, RuntimeFault
  ## ee.detail.__xmlele[0][0] is an XSD::QName object, with accessors name and namespace
  ## ee.detail.__xmlele[0][1] is a VMware::VIM25::xxx fault object
  vim_fault = ee.detail.__xmlele[0][1]
  case vim_fault.class
  when VMware::VIM25::InvalidLogin
  when VMware::VIM25::InvalidLocale
  when VMware::VIM25::NoPermission
  when VMware::VIM25::RuntimeFault
rob