Class: Savon::LocalOptions
- Includes:
- SharedOptions
- Defined in:
- lib/savon/options.rb
Overview
Per-request options passed to client.call. Overrides or extends the matching GlobalOptions for a single SOAP operation.
Instance Attribute Summary
Attributes inherited from Options
Instance Method Summary collapse
-
#advanced_typecasting(advanced) ⇒ Object
Instruct Nori to use advanced typecasting.
-
#attachments(attachments) ⇒ Object
Attachments for the SOAP message (https://www.w3.org/TR/SOAP-attachments).
-
#attributes(attributes) ⇒ Object
Attributes for the SOAP message tag.
-
#cookies(cookies) ⇒ Object
Cookies to be used for the next request.
-
#headers(headers) ⇒ Object
Per-request HTTP headers.
-
#initialize(options = {}) ⇒ LocalOptions
constructor
A new instance of LocalOptions.
-
#message(message) ⇒ Object
The SOAP message to send.
-
#message_tag(message_tag) ⇒ Object
SOAP message tag (formerly known as SOAP input tag).
-
#multipart(multipart) ⇒ Object
Instruct Savon to create a multipart response if available.
-
#response_parser(parser) ⇒ Object
Instruct Nori to use :rexml or :nokogiri to parse the response.
-
#soap_action(soap_action) ⇒ Object
Value of the SOAPAction HTTP header.
-
#soap_header(header) ⇒ Object
The local SOAP header.
-
#xml(xml) ⇒ Object
The SOAP request XML to send.
Methods included from SharedOptions
#wsse_auth, #wsse_signature, #wsse_timestamp
Methods inherited from Options
Constructor Details
#initialize(options = {}) ⇒ LocalOptions
Returns a new instance of LocalOptions.
496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/savon/options.rb', line 496 def initialize( = {}) @option_type = :local defaults = { advanced_typecasting: true, response_parser: :nokogiri, multipart: false } super defaults.merge() 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.
581 582 583 |
# File 'lib/savon/options.rb', line 581 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
param1: 'value'
[
{ filename: 'x1.xml', content: '<xml>abc</xml>'},
{ filename: 'x2.xml', content: '<xml>abc</xml>'}
]
end
# Content-ID will be x1.xml and x2.xml
response = client.call :operation1 do
param1: 'value'
'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
param1: 'value'
[ '/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
561 562 563 |
# File 'lib/savon/options.rb', line 561 def () @options[:attachments] = end |
#attributes(attributes) ⇒ Object
Attributes for the SOAP message tag.
527 528 529 |
# File 'lib/savon/options.rb', line 527 def attributes(attributes) @options[:attributes] = attributes end |
#cookies(cookies) ⇒ Object
Cookies to be used for the next request.
571 572 573 |
# File 'lib/savon/options.rb', line 571 def () @options[:cookies] = end |
#headers(headers) ⇒ Object
Per-request HTTP headers. Merged with global headers for each request.
602 603 604 |
# File 'lib/savon/options.rb', line 602 def headers(headers) @options[:headers] = headers end |
#message(message) ⇒ Object
The SOAP message to send. Expected to be a Hash or a String.
516 517 518 |
# File 'lib/savon/options.rb', line 516 def () @options[: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.
522 523 524 |
# File 'lib/savon/options.rb', line 522 def () @options[:message_tag] = end |
#multipart(multipart) ⇒ Object
Instruct Savon to create a multipart response if available.
591 592 593 594 595 596 597 598 599 |
# File 'lib/savon/options.rb', line 591 def multipart(multipart) if multipart warn "The local :multipart option has been a no-op since v2.13.0. " \ "Savon detects whether the response is multipart by checking if the " \ "response Content-Type header contains 'multipart'. You can remove" \ "this option from your code to make this warning disappear.", uplevel: 1 end @options[:multipart] = multipart end |
#response_parser(parser) ⇒ Object
Instruct Nori to use :rexml or :nokogiri to parse the response.
586 587 588 |
# File 'lib/savon/options.rb', line 586 def response_parser(parser) @options[:response_parser] = parser end |
#soap_action(soap_action) ⇒ Object
Value of the SOAPAction HTTP header.
566 567 568 |
# File 'lib/savon/options.rb', line 566 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.
511 512 513 |
# File 'lib/savon/options.rb', line 511 def soap_header(header) @options[:soap_header] = header end |
#xml(xml) ⇒ Object
The SOAP request XML to send. Expected to be a String.
576 577 578 |
# File 'lib/savon/options.rb', line 576 def xml(xml) @options[:xml] = xml end |