lib/lolsoap/request.rb in lolsoap-0.1.4 vs lib/lolsoap/request.rb in lolsoap-0.2.0
- old
+ new
@@ -1,12 +1,14 @@
module LolSoap
# Represents a HTTP request containing a SOAP Envelope
class Request
- attr_reader :envelope
+ attr_reader :envelope
+ attr_accessor :xml_options
def initialize(envelope)
- @envelope = envelope
+ @envelope = envelope
+ @xml_options = {}
end
# @see Envelope#body
def body(&block)
envelope.body(&block)
@@ -20,10 +22,15 @@
# Namespace used for SOAP envelope tags
def soap_namespace
envelope.soap_namespace
end
+ # The SOAP version in use
+ def soap_version
+ envelope.soap_version
+ end
+
# URL to be POSTed to
def url
envelope.endpoint
end
@@ -38,11 +45,15 @@
end
# The MIME type of the request. This is always application/soap+xml,
# but it could be overridden in a subclass.
def mime
- 'application/soap+xml'
+ if soap_version == '1.1'
+ 'text/xml'
+ else
+ 'application/soap+xml'
+ end
end
# The charset of the request. This is always UTF-8, but it could be
# overridden in a subclass.
def charset
@@ -64,9 +75,9 @@
}
end
# The content to be sent in the HTTP request
def content
- @content ||= envelope.to_xml
+ @content ||= envelope.to_xml(xml_options)
end
end
end