Class: WinRM::WSMV::ReceiveResponseReader

Inherits:
Object
  • Object
show all
Includes:
Header, SOAP
Defined in:
lib/winrm/wsmv/receive_response_reader.rb

Overview

Class for reading wsmv Receive_Response messages

Direct Known Subclasses

PSRP::ReceiveResponseReader

Constant Summary

Constants included from Header

Header::RESOURCE_URI_CMD, Header::RESOURCE_URI_POWERSHELL

Constants included from SOAP

SOAP::NS_ADDRESSING, SOAP::NS_CIMBINDING, SOAP::NS_ENUM, SOAP::NS_SCHEMA_INST, SOAP::NS_SOAP_ENV, SOAP::NS_TRANSFER, SOAP::NS_WIN_SHELL, SOAP::NS_WSMAN_CONF, SOAP::NS_WSMAN_DMTF, SOAP::NS_WSMAN_FAULT, SOAP::NS_WSMAN_MSFT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Header

#action_command, #action_delete, #action_enumerate, #action_enumerate_pull, #action_get, #action_receive, #action_send, #action_signal, #merge_headers, #resource_uri_cmd, #resource_uri_shell, #resource_uri_wmi, #selector_shell_id, #shared_headers

Methods included from SOAP

#namespaces

Constructor Details

#initialize(transport, logger) ⇒ ReceiveResponseReader

Creates a new ReceiveResponseReader

Parameters:

  • transport (HttpTransport)

    The WinRM SOAP transport

  • logger (Logger)

    The logger to log diagnostic messages to



30
31
32
33
34
# File 'lib/winrm/wsmv/receive_response_reader.rb', line 30

def initialize(transport, logger)
  @transport = transport
  @logger = logger
  @output_decoder = CommandOutputDecoder.new
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



36
37
38
# File 'lib/winrm/wsmv/receive_response_reader.rb', line 36

def logger
  @logger
end

Instance Method Details

#read_output(wsmv_message) {|standard, standard| ... } ⇒ Object

Reads streams and returns decoded output

Parameters:

Yield Parameters:

  • standard (string)

    out response text

  • standard (string)

    error response text

Yield Returns:



43
44
45
46
47
48
49
50
# File 'lib/winrm/wsmv/receive_response_reader.rb', line 43

def read_output(wsmv_message)
  with_output do |output|
    read_response(wsmv_message, true) do |stream, doc|
      handled_out = handle_stream(stream, output, doc)
      yield handled_out if handled_out && block_given?
    end
  end
end

#read_response(wsmv_message, wait_for_done_state = false) {|Hash, Complete| ... } ⇒ Object

Reads streams sent in one or more receive response messages

Parameters:

  • wsmv_message (WinRM::WSMV::Base)

    A wsmv message to send to endpoint

  • wait_for_done_state (defaults to: false)

    whether to poll for a CommandState of Done

Yield Parameters:

  • Hash (Hash)

    representation of stream with type and text

  • Complete (REXML::Document)

    SOAP envelope returned to wsmv_message



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/winrm/wsmv/receive_response_reader.rb', line 57

def read_response(wsmv_message, wait_for_done_state = false)
  resp_doc = nil
  until command_done?(resp_doc, wait_for_done_state)
    logger.debug('[WinRM] Waiting for output...')
    resp_doc = send_get_output_message(wsmv_message.build)
    logger.debug('[WinRM] Processing output')
    read_streams(resp_doc) do |stream|
      yield stream, resp_doc
    end
  end
end