Class: Viewpoint::SPWS::Connection
- Inherits:
-
Object
- Object
- Viewpoint::SPWS::Connection
- Includes:
- Viewpoint::SPWS
- Defined in:
- lib/viewpoint/spws/connection.rb
Constant Summary
Constants included from Viewpoint::SPWS
Instance Attribute Summary collapse
-
#site_base ⇒ Object
readonly
Returns the value of attribute site_base.
Attributes included from Viewpoint::SPWS
Instance Method Summary collapse
-
#authenticate(websvc) ⇒ Boolean
Authenticate to the web service.
-
#get(websvc) ⇒ String
Send a GET to the web service.
-
#initialize(site_base) ⇒ Connection
constructor
A new instance of Connection.
-
#post(websvc, xmldoc) ⇒ String
Send a POST to the web service.
- #set_auth(user, pass) ⇒ Object
Methods included from Viewpoint::SPWS
Constructor Details
#initialize(site_base) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 12 13 14 |
# File 'lib/viewpoint/spws/connection.rb', line 8 def initialize(site_base) @log = Logging.logger[self.class.name.to_s.to_sym] @httpcli = HTTPClient.new # Up the keep-alive so we don't have to do the NTLM dance as often. @httpcli.keep_alive_timeout = 60 @site_base = URI.parse(normalize_site_name(site_base)) end |
Instance Attribute Details
#site_base ⇒ Object (readonly)
Returns the value of attribute site_base.
4 5 6 |
# File 'lib/viewpoint/spws/connection.rb', line 4 def site_base @site_base end |
Instance Method Details
#authenticate(websvc) ⇒ Boolean
Authenticate to the web service. You don’t have to do this because authentication will happen on the first request if you don’t do it here.
23 24 25 |
# File 'lib/viewpoint/spws/connection.rb', line 23 def authenticate(websvc) self.get(websvc) && true end |
#get(websvc) ⇒ String
Send a GET to the web service
30 31 32 |
# File 'lib/viewpoint/spws/connection.rb', line 30 def get(websvc) check_response( @httpcli.get(@site_base + URI.encode(websvc)) ) end |
#post(websvc, xmldoc) ⇒ String
Send a POST to the web service
37 38 39 40 41 |
# File 'lib/viewpoint/spws/connection.rb', line 37 def post(websvc, xmldoc) headers = {'Content-Type' => 'application/soap+xml; charset=utf-8'} url = (@site_base + websvc).to_s check_response( @httpcli.post(url, xmldoc, headers) ) end |
#set_auth(user, pass) ⇒ Object
16 17 18 |
# File 'lib/viewpoint/spws/connection.rb', line 16 def set_auth(user,pass) @httpcli.set_auth(@site_base.to_s, user, pass) end |