View Single Post
  #5 (permalink)  
Old 11-21-2005, 12:22 PM
bhwang bhwang is offline
Zimbra Employee
 
Posts: 6
Default SOAP & ruby

One way to achieve this is to use soap document style encoding. This basically means that the code will get the raw xml structure back and has to do its own parsing.

Here is an example on how to do that, following the same code


Code:
...

def GetNamePair(response)
  response.account.each do |x| 
    class << x
      attr :configuration, true    
    end     
    x.configuration = Hash[*x.a.map do |y|
      [y.__xmlattr[XSD::QName.new(nil, 'n')], String.new(y)]
    end.flatten] 
  end
end

mNS = 'urn:zimbraAdmin'
drv.add_document_method('GetAllAdminAccountsRequest', mNS, [XSD::QName.new(mNS, 'GetAllAdminAccountsRequest')],  
  [XSD::QName.new(mNS, 'GetAllAdminAccountsResponse')] )  

puts YAML.dump(GetNamePair(drv.GetAllAdminAccountsRequest([]))

Last edited by bhwang : 11-21-2005 at 12:26 PM.
Reply With Quote