Class: ONVIF::Message
- Inherits:
-
Object
- Object
- ONVIF::Message
- Defined in:
- lib/ruby_onvif_client/message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
writeonly
Sets the attribute body.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(options = {}) ⇒ Message
constructor
A new instance of Message.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Message
Returns a new instance of Message.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby_onvif_client/message.rb', line 10 def initialize = {} @options = { username: 'admin', password: 'admin', namespaces: {} }.merge() @namespaces = { :'xmlns:soap' => "http://www.w3.org/2003/05/soap-envelope", :'xmlns:wsdl' => "http://www.onvif.org/ver10/device/wsdl" }.merge(@options[:namespaces]) self.username = @options[:username] self.password = @options[:password] end |
Instance Attribute Details
#body=(value) ⇒ Object (writeonly)
Sets the attribute body
7 8 9 |
# File 'lib/ruby_onvif_client/message.rb', line 7 def body=(value) @body = value end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/ruby_onvif_client/message.rb', line 8 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/ruby_onvif_client/message.rb', line 8 def username @username end |
Instance Method Details
#header ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ruby_onvif_client/message.rb', line 25 def header wsse = Akami.wsse wsse.credentials(username, password) wsse.created_at = Time.now wsse.to_xml %Q{<wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-31"><wsse:Username>#{username}</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">#{password}</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">vwqgTTRK/D2IeOTP76JHBw==</wsse:Nonce><wsu:Created>2013-08-06T10:22:17.028Z</wsu:Created></wsse:UsernameToken></wsse:Security>} end |
#to_s ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ruby_onvif_client/message.rb', line 33 def to_s Builder::XmlMarkup.new(indent: 4).soap(:Envelope, @namespaces) do |xml| xml.soap(:Header) do xml << header end xml.soap(:Body) do @body.call(xml) if @body.class == Proc end end end |