Class: Savon::LocalOptions

Inherits:
Options
  • Object
show all
Includes:
SharedOptions
Defined in:
lib/savon/options.rb

Instance Attribute Summary

Attributes inherited from Options

#option_type

Instance Method Summary collapse

Methods included from SharedOptions

#wsse_auth, #wsse_signature, #wsse_timestamp

Methods inherited from Options

#[], #[]=, #deprecate, #include?

Constructor Details

#initialize(options = {}) ⇒ LocalOptions

Returns a new instance of LocalOptions.



393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/savon/options.rb', line 393

def initialize(options = {})
  @option_type = :local

  defaults = {
    :advanced_typecasting => true,
    :response_parser      => :nokogiri,
    :multipart            => false,
    :body                 => false,
    :mtom                 => false
  }

  super defaults.merge(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Savon::Options

Instance Method Details

#advanced_typecasting(advanced) ⇒ Object

Instruct Nori to use advanced typecasting.



489
490
491
# File 'lib/savon/options.rb', line 489

def advanced_typecasting(advanced)
  @options[:advanced_typecasting] = advanced
end

#attachments(attachments) ⇒ Object

Attachments for the SOAP message (https://www.w3.org/TR/SOAP-attachments)

should pass an Array or a Hash; items should be path strings or { filename: 'file.name', content: 'content' } objects The Content-ID in multipart message sections will be the filename or the key if Hash is given

usage examples:

response = client.call :operation1 do message param1: 'value' attachments [ { filename: 'x1.xml', content: 'abc'}, { filename: 'x2.xml', content: 'abc'} ] end # Content-ID will be x1.xml and x2.xml

response = client.call :operation1 do message param1: 'value' attachments 'x1.xml' => '/tmp/1281ab7d7d.xml', 'x2.xml' => '/tmp/4c5v8e833a.xml' end # Content-ID will be x1.xml and x2.xml

response = client.call :operation1 do message param1: 'value' attachments [ '/tmp/1281ab7d7d.xml', '/tmp/4c5v8e833a.xml'] end # Content-ID will be 1281ab7d7d.xml and 4c5v8e833a.xml

The Content-ID is important if you want to refer to the attachments from the SOAP request



460
461
462
# File 'lib/savon/options.rb', line 460

def attachments(attachments)
  @options[:attachments] = attachments
end

#attributes(attributes) ⇒ Object

Attributes for the SOAP message tag.



426
427
428
# File 'lib/savon/options.rb', line 426

def attributes(attributes)
  @options[:attributes] = attributes
end

#body(body) ⇒ Object



512
513
514
# File 'lib/savon/options.rb', line 512

def body(body)
  @options[:body] = body
end

#cookies(cookies) ⇒ Object

Cookies to be used for the next request and empty string, set it to ""

=> "accept=application/json; some-cookie=foo; empty-cookie=; HttpOnly"

Examples:

cookies('application/json', some-cookie: 'foo', "empty-cookie": "", HttpOnly: nil)

Parameters:

  • cookies (Hash)

    cookies associated to nil will be appended as array cookies, if you need a cookie equal to



479
480
481
# File 'lib/savon/options.rb', line 479

def cookies(cookies)
  @options[:cookies] = cookies
end

#headers(headers) ⇒ Object



508
509
510
# File 'lib/savon/options.rb', line 508

def headers(headers)
  @options[:headers] = headers
end

#message(message) ⇒ Object

The SOAP message to send. Expected to be a Hash or a String.



415
416
417
# File 'lib/savon/options.rb', line 415

def message(message)
  @options[:message] = message
end

#message_tag(message_tag) ⇒ Object

SOAP message tag (formerly known as SOAP input tag). If it's not set, Savon retrieves the name from the WSDL document (if available). Otherwise, Gyoku converts the operation name into an XML element.



421
422
423
# File 'lib/savon/options.rb', line 421

def message_tag(message_tag)
  @options[:message_tag] = message_tag
end

#mtom(mtom) ⇒ Object

Instruct Savon to send attachments using MTOM https://www.w3.org/TR/soap12-mtom/



465
466
467
# File 'lib/savon/options.rb', line 465

def mtom(mtom)
  @options[:mtom] = mtom
end

#multipart(multipart) ⇒ Object

Instruct Savon to create a multipart response if available.



504
505
506
# File 'lib/savon/options.rb', line 504

def multipart(multipart)
  @options[:multipart] = multipart
end

#nori(nori) ⇒ Object

Pass already configured Nori instance.



499
500
501
# File 'lib/savon/options.rb', line 499

def nori(nori)
  @options[:nori] = nori
end

#response_parser(parser) ⇒ Object

Instruct Nori to use :rexml or :nokogiri to parse the response.



494
495
496
# File 'lib/savon/options.rb', line 494

def response_parser(parser)
  @options[:response_parser] = parser
end

#soap_action(soap_action) ⇒ Object

Value of the SOAPAction HTTP header.



470
471
472
# File 'lib/savon/options.rb', line 470

def soap_action(soap_action)
  @options[:soap_action] = soap_action
end

#soap_header(header) ⇒ Object

The local SOAP header. Expected to be a Hash or respond to #to_s. Will be merged with the global SOAP header if both are Hashes. Otherwise the local option will be preferred.



410
411
412
# File 'lib/savon/options.rb', line 410

def soap_header(header)
  @options[:soap_header] = header
end

#xml(xml) ⇒ Object

The SOAP request XML to send. Expected to be a String.



484
485
486
# File 'lib/savon/options.rb', line 484

def xml(xml)
  @options[:xml] = xml
end