Class List Method List File List

# Class: SSO::SoapInvocable Abstract

Inherits:
  Object
  - Object
  - SSO::SoapInvocable
  show all
Defined in:
  /build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb

## Overview

This class is abstract.

Base class for invocable service calls.

## Direct Known Subclasses

RequestSecurityToken

## Instance Attribute Summary (collapse)

- - (Object) client readonly

  Returns the value of attribute client.

- - (Object) operation readonly

  Returns the value of attribute operation.

- - (Object) response readonly

  Returns the value of attribute response.

## Instance Method Summary (collapse)

- - (Object) body_xml(body)

  Builds the body portion of the SOAP request.

- - (Boolean) has_header?
- - (Object) header_xml(header)

  Builds the header portion of the SOAP request.

- - (SoapInvocable) initialize(operation, client) constructor

  Constructs a new instance.

- - (Object) invoke

  Invokes the service call represented by this type.

- - (Object) request_xml

  Builds the request XML content.

- - (Object) response_hash
- - (Object) response_xml

  Gets the response XML content.

## Constructor Details

### - (`SoapInvocable`) initialize(operation, client)

Constructs a new instance.

Parameters:

- operation (`Symbol`) —

  the SOAP operation name (in Symbol form)

- client (`Savon::Client`) —

  the client

    92
    93
    94
    95
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 92

    def initialize(operation, client)
        @operation = operation
        @client = client
    end

## Instance Attribute Details

### - (`Object`) client (readonly)

Returns the value of attribute client

    87
    88
    89
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 87

    def client
      @client
    end

### - (`Object`) operation (readonly)

Returns the value of attribute operation

    87
    88
    89
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 87

    def operation
      @operation
    end

### - (`Object`) response (readonly)

Returns the value of attribute response

    87
    88
    89
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 87

    def response
      @response
    end

## Instance Method Details

### - (`Object`) body_xml(body)

Builds the body portion of the SOAP request. Specific service operations must override this method.

    136
    137
    138
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 136

    def body_xml(body)
        raise 'abstract method not implemented!'
    end

### - (`Boolean`) has_header?

Returns:

- (`Boolean`)

    124
    125
    126
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 124

    def has_header?
        true
    end

### - (`Object`) header_xml(header)

Builds the header portion of the SOAP request. Specific service operations must override this method.

    130
    131
    132
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 130

    def header_xml(header)
        raise 'abstract method not implemented!'
    end

### - (`Object`) invoke

Invokes the service call represented by this type.

    98
    99
    100
    101
    102
    103
    104
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 98

    def invoke
        request = request_xml.to_s
        puts "request = #{request}" if ENV['DEBUG']
        @response = client.call(operation, xml:request)
        puts "response = #{response}" if ENV['DEBUG']
        self # for chaining with new
    end

### - (`Object`) request_xml

Builds the request XML content.

    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 107

    def request_xml
        builder = Builder::XmlMarkup.new()
        builder.instruct!(:xml, encoding: "UTF-8")

        builder.tag!("S:Envelope", NAMESPACES) do |envelope|
            if has_header?
                envelope.tag!("S:Header") do |header|
                    header_xml(header)
                end
            end
            envelope.tag!("S:Body") do |body|
                body_xml(body)
            end
        end
        builder.target!
    end

### - (`Object`) response_hash

    146
    147
    148
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 146

    def response_hash
        @response_hash ||= response.to_hash
    end

### - (`Object`) response_xml

Gets the response XML content.

    141
    142
    143
    144
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 141

    def response_xml
        raise 'illegal state: response not set yet' if response.nil?
        @response_xml ||= Nokogiri::XML(response.to_xml)
    end