lib/savon/soap.rb in savon-0.7.4 vs lib/savon/soap.rb in savon-0.7.5
- old
+ new
@@ -4,29 +4,38 @@
#
# Represents the SOAP parameters and envelope.
class SOAP
# SOAP namespaces by SOAP version.
- SOAPNamespace = {
+ Namespace = {
1 => "http://schemas.xmlsoap.org/soap/envelope/",
2 => "http://www.w3.org/2003/05/soap-envelope"
}
# Content-Types by SOAP version.
ContentType = { 1 => "text/xml", 2 => "application/soap+xml" }
+ # Supported SOAP versions.
+ Versions = [1, 2]
+
+ # SOAP xs:dateTime format.
+ DateTimeFormat = "%Y-%m-%dT%H:%M:%SZ"
+
+ # SOAP xs:dateTime Regexp.
+ DateTimeRegexp = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
+
# The global SOAP version.
@@version = 1
# Returns the global SOAP version.
def self.version
@@version
end
# Sets the global SOAP version.
def self.version=(version)
- @@version = version if Savon::SOAPVersions.include? version
+ @@version = version if Versions.include? version
end
# Sets the global SOAP header. Expected to be a Hash that can be translated
# to XML via Hash.to_soap_xml or any other Object responding to to_s.
def self.header=(header)
@@ -49,11 +58,13 @@
def self.namespaces
@@namespaces ||= {}
end
# Initialzes the SOAP object.
- def initialize
+ def initialize(operation, endpoint)
+ @action, @input = operation[:action], operation[:input]
+ @endpoint = endpoint.kind_of?(URI) ? endpoint : URI(endpoint)
@builder = Builder::XmlMarkup.new
end
# Sets the WSSE options.
attr_writer :wsse
@@ -95,21 +106,21 @@
attr_writer :namespaces
# Returns the namespaces. A Hash containing the namespaces (keys)
# and the corresponding URI's (values).
def namespaces
- @namespaces ||= { "xmlns:env" => SOAPNamespace[version] }
+ @namespaces ||= { "xmlns:env" => Namespace[version] }
end
# Convenience method for setting the "xmlns:wsdl" namespace.
def namespace=(namespace)
namespaces["xmlns:wsdl"] = namespace
end
# Sets the SOAP version.
def version=(version)
- @version = version if Savon::SOAPVersions.include? version
+ @version = version if Versions.include? version
end
# Returns the SOAP version. Defaults to the global default.
def version
@version ||= self.class.version
@@ -159,12 +170,18 @@
# Returns an Array of SOAP input names to append to the :wsdl namespace.
# Defaults to use the name of the SOAP action and may be an empty Array
# in case the specified SOAP input seems invalid.
def input_array
- return input.map { |i| i.is_a?(Hash) ? i : i.to_sym } unless input.blank?
- return [action.to_sym] unless action.blank?
- []
+ if !input.blank? && input.kind_of?(Array)
+ [input[0].to_sym, input[1]]
+ elsif !input.blank?
+ [input.to_sym]
+ elsif action.blank?
+ [action.to_sym]
+ else
+ []
+ end
end
end
end