Class: ActiveSP::Site::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/activesp/site.rb

Instance Method Summary collapse

Constructor Details

#initialize(site, name) ⇒ Service

Returns a new instance of Service.



279
280
281
282
283
# File 'lib/activesp/site.rb', line 279

def initialize(site, name)
  @site, @name = site, name
  @client = Savon::Client.new(::File.join(URI.escape(site.url), "_vti_bin", name + ".asmx?WSDL"))
  @client.request.ntlm_auth(site.connection., site.connection.password) if site.connection.
end

Instance Method Details

#call(m, *args) ⇒ Object



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/activesp/site.rb', line 285

def call(m, *args)
  t1 = Time.now
  if Hash === args[-1]
    body = args.pop
  end
  @client.send(m, *args) do |soap|
    if body
      soap.body = body.inject({}) { |h, (k, v)| h["wsdl:#{k}"] = v ; h }
    end
    yield soap if block_given?
  end
ensure
  t2 = Time.now
  puts "SP - time: %.3fs, site: %s, service: %s, method: %s, body: %s" % [t2 - t1, @site.url, @name, m, body.inspect] if @site.connection.trace
end