consume .NET in rails


What is the preferred way to consume .NET webservices in rails? Currently we have a file in the lib directory handling all this but I would like a cleaner way to

1 - have the services act more “model” like so we can access data like NETApi.get_users()

2 - Allow the rails client to login only once, as logging in each time for a request can be very slow on a very large wsdl file

Any suggestions? I am using soap4r now and it works fine but I think it can be tidier. Also logging in to the NET site on startup slows down launching future rails instances. Some sample below

module NETAPILibrary

require ‘soap/wsdlDriver’

require ‘soap/header/simplehandler’

require ‘uuid’

class AutheticationHeaderHandler < SOAP::Header::SimpleHandler

#The header is named “SecureHeader” in this web service.

@@HEADER_NAME = ‘AuthenticationHeader’

def initialize(namespace, companyID, userID)

super(, @@HEADER_NAME))

@user_element =, ‘CompanyId’)

@password_element =, ‘UserId’)

@companyID, @userID = companyID, userID


def on_simple_outbound

{@user_element => @companyID, @password_element => @userID}



def bt_initialize

$soap =$BT_WSDL_URL).create_rpc_driver

$soap.headerhandler <<“”, $bt_rootid,$bt_user_id)


def bt_getmemberbyemail(email)

res = $soap.GetMemberByEmail(:email => email)

return res.getMemberByEmailResult.iD