module WinRM::WSMV::Header

SOAP header utility mixin

Constants

RESOURCE_URI_CMD

WSMan URI of the regular Windows cmd shell

RESOURCE_URI_POWERSHELL

WSMan URI for PowerShell

Public Instance Methods

action_command() click to toggle source
# File lib/winrm/wsmv/header.rb, line 126
def action_command
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
action_delete() click to toggle source
# File lib/winrm/wsmv/header.rb, line 114
def action_delete
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
action_enumerate() click to toggle source
# File lib/winrm/wsmv/header.rb, line 174
def action_enumerate
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
action_enumerate_pull() click to toggle source
# File lib/winrm/wsmv/header.rb, line 186
def action_enumerate_pull
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
action_get() click to toggle source
# File lib/winrm/wsmv/header.rb, line 102
def action_get
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
action_receive() click to toggle source
# File lib/winrm/wsmv/header.rb, line 138
def action_receive
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
action_send() click to toggle source
# File lib/winrm/wsmv/header.rb, line 150
def action_send
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
action_signal() click to toggle source
# File lib/winrm/wsmv/header.rb, line 162
def action_signal
  {
    "#{SOAP::NS_ADDRESSING}:Action" =>
    'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal',
    :attributes! => {
      "#{SOAP::NS_ADDRESSING}:Action" => {
        'mustUnderstand' => true
      }
    }
  }
end
merge_headers(*headers) click to toggle source

Merge the various header hashes and make sure we carry all of the attributes through instead of overwriting them.

# File lib/winrm/wsmv/header.rb, line 32
def merge_headers(*headers)
  hdr = {}
  headers.each do |h|
    hdr.merge!(h) do |k, v1, v2|
      v1.merge!(v2) if k == :attributes!
    end
  end
  hdr
end
resource_uri_cmd() click to toggle source
# File lib/winrm/wsmv/header.rb, line 86
def resource_uri_cmd
  resource_uri_shell(RESOURCE_URI_CMD)
end
resource_uri_shell(shell_uri) click to toggle source

Helper methods for SOAP Headers

# File lib/winrm/wsmv/header.rb, line 76
def resource_uri_shell(shell_uri)
  {
    "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => shell_uri, :attributes! => {
      "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => {
        'mustUnderstand' => true
      }
    }
  }
end
resource_uri_wmi(namespace = 'root/cimv2/*') click to toggle source
# File lib/winrm/wsmv/header.rb, line 90
def resource_uri_wmi(namespace = 'root/cimv2/*')
  {
    "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" =>
    "http://schemas.microsoft.com/wbem/wsman/1/wmi/#{namespace}",
    :attributes! => {
      "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => {
        'mustUnderstand' => true
      }
    }
  }
end
selector_shell_id(shell_id) click to toggle source
# File lib/winrm/wsmv/header.rb, line 198
def selector_shell_id(shell_id)
  {
    "#{SOAP::NS_WSMAN_DMTF}:SelectorSet" => {
      "#{SOAP::NS_WSMAN_DMTF}:Selector" => shell_id, :attributes! => {
        "#{SOAP::NS_WSMAN_DMTF}:Selector" => {
          'Name' => 'ShellId'
        }
      }
    }
  }
end
shared_headers(session_opts) click to toggle source
# File lib/winrm/wsmv/header.rb, line 42
def shared_headers(session_opts)
  {
    "#{SOAP::NS_ADDRESSING}:To" => session_opts[:endpoint],
    "#{SOAP::NS_ADDRESSING}:ReplyTo" => {
      "#{SOAP::NS_ADDRESSING}:Address" =>
        'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous',
      :attributes! => {
        "#{SOAP::NS_ADDRESSING}:Address" => {
          'mustUnderstand' => true
        }
      }
    },
    "#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => session_opts[:max_envelope_size],
    "#{SOAP::NS_ADDRESSING}:MessageID" => "uuid:#{SecureRandom.uuid.to_s.upcase}",
    "#{SOAP::NS_WSMAN_MSFT}:SessionId" => "uuid:#{session_opts[:session_id]}",
    "#{SOAP::NS_WSMAN_DMTF}:Locale/" => '',
    "#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => '',
    "#{SOAP::NS_WSMAN_DMTF}:OperationTimeout" =>
      Iso8601Duration.sec_to_dur(session_opts[:operation_timeout]),
    :attributes! => {
      "#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => { 'mustUnderstand' => true },
      "#{SOAP::NS_WSMAN_DMTF}:Locale/" => {
        'xml:lang' => session_opts[:locale], 'mustUnderstand' => false
      },
      "#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => {
        'xml:lang' => session_opts[:locale], 'mustUnderstand' => false
      },
      "#{SOAP::NS_WSMAN_MSFT}:SessionId" => { 'mustUnderstand' => false }
    }
  }
end