savon 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,10 +1,22 @@
1
+ == 0.7.3 (2010-01-31)
2
+ * Added support for Geotrust-style WSDL documents (Julian Kornberger <github.corny@digineo.de>).
3
+ * Make HTTP requests include path and query only. This was breaking requests via proxy as scheme and host
4
+ were repeated (Adrian Mugnolo <adrian@mugnolo.com>)
5
+ * Avoid warning on 1.8.7 and 1.9.1 (Adrian Mugnolo <adrian@mugnolo.com>).
6
+ * Fix for issue #29 (WSSE Created Bug?). Default to UTC to xs:dateTime value for WSSE authentication.
7
+ * Fix for issue #28 (Undefined Method ssl? on URI::Generic).
8
+ * Fix for issue #27 (http content-type defaults to utf-8). The Content-Type now defaults to UTF-8.
9
+ * Modification to allow assignment of an Array with an input name and an optional Hash of values to soap.input.
10
+ Patches issue #30 (stanleydrew <andrewmbenton@gmail.com>).
11
+ * Fix for issue #25 (header-tag should not be sent if not set).
12
+
1
13
  == 0.7.2 (2010-01-17)
2
14
  * Exposed the Net::HTTP response (added by Kevin Ingolfsland). Use the "http" accessor (response.http) on your
3
15
  Savon::Response to access the Net::HTTP response object.
4
- * Fix for Github issue #21 (savon is stripping ?SOAP off the end of WSDL locations).
5
- * Fix for Github issue #22 (REXML::ParseException parsing 401 Unauthorized response body).
6
- * Fix for Github issue #19 (Unable to set attribute in name-spaced WSSE password element).
7
- * Added support for global header and namespaces. See Github issue #9 (Setting headers and namespaces).
16
+ * Fix for issue #21 (savon is stripping ?SOAP off the end of WSDL locations).
17
+ * Fix for issue #22 (REXML::ParseException parsing 401 Unauthorized response body).
18
+ * Fix for issue #19 (Unable to set attribute in name-spaced WSSE password element).
19
+ * Added support for global header and namespaces. See issue #9 (Setting headers and namespaces).
8
20
 
9
21
  == 0.7.1 (2010-01-10)
10
22
  * The Hash of HTTP headers for SOAP calls is now public via Savon::Request#headers.
@@ -2,11 +2,7 @@ h1. Savon
2
2
 
3
3
  h4. Heavy metal Ruby SOAP client library
4
4
 
5
- p. "RDoc":http://rdoc.info/projects/rubiii/savon | "Wiki":http://wiki.github.com/rubiii/savon | "ToDo":http://rubiii.tadalist.com/lists/1459816/public | "Metrics":http://getcaliper.com/caliper/project?repo=git://github.com/rubiii/savon.git
6
-
7
- h2. Warning
8
-
9
- p. Savon 0.7.0 comes with several changes to the public API. Pay attention to the CHANGELOG and the updated Wiki.
5
+ p. "RDoc":http://rdoc.info/projects/rubiii/savon | "Wiki":http://wiki.github.com/rubiii/savon | "Metrics":http://getcaliper.com/caliper/project?repo=git://github.com/rubiii/savon.git
10
6
 
11
7
  h2. Installation
12
8
 
@@ -4,7 +4,7 @@ module Savon
4
4
  SOAPVersions = [1, 2]
5
5
 
6
6
  # SOAP xs:dateTime format.
7
- SOAPDateTimeFormat = "%Y-%m-%dT%H:%M:%S"
7
+ SOAPDateTimeFormat = "%Y-%m-%dT%H:%M:%SZ"
8
8
 
9
9
  # SOAP xs:dateTime Regexp.
10
10
  SOAPDateTimeRegexp = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
@@ -18,17 +18,13 @@ module Savon
18
18
  end
19
19
 
20
20
  # standard libs
21
- %w(logger net/https openssl base64 digest/sha1 rexml/document).each do |lib|
22
- require lib
23
- end
21
+ stdlibs = %w(logger net/https openssl base64 digest/sha1 rexml/document)
22
+ stdlibs.each { |stdlib| require stdlib }
24
23
 
25
24
  # gems
26
- require "rubygems"
27
- %w(builder crack/xml).each do |gem|
28
- require gem
29
- end
25
+ gems = %w(builder crack/xml)
26
+ gems.each { |gem| require gem }
30
27
 
31
28
  # core files
32
- %w(core_ext wsse soap request response wsdl client).each do |file|
33
- require File.dirname(__FILE__) + "/savon/#{file}"
34
- end
29
+ files = %w(core_ext wsse soap request response wsdl_stream wsdl client)
30
+ files.each { |file| require "savon/#{file}" }
@@ -1,3 +1,2 @@
1
- %w(object string symbol datetime hash uri net_http).each do |file|
2
- require File.dirname(__FILE__) + "/core_ext/#{file}"
3
- end
1
+ files = %w(object string symbol datetime hash uri net_http)
2
+ files.each { |file| require "savon/core_ext/#{file}" }
@@ -1,5 +1,5 @@
1
1
  module URI
2
- class HTTP
2
+ class Generic
3
3
 
4
4
  # Returns whether the URI hints to SSL.
5
5
  def ssl?
@@ -7,4 +7,4 @@ module URI
7
7
  end
8
8
 
9
9
  end
10
- end
10
+ end
@@ -6,7 +6,7 @@ module Savon
6
6
  class Request
7
7
 
8
8
  # Content-Types by SOAP version.
9
- ContentType = { 1 => "text/xml", 2 => "application/soap+xml" }
9
+ ContentType = { 1 => "text/xml;charset=UTF-8", 2 => "application/soap+xml;charset=UTF-8" }
10
10
 
11
11
  # Whether to log HTTP requests.
12
12
  @@log = true
@@ -108,7 +108,7 @@ module Savon
108
108
  # Logs the SOAP request.
109
109
  def log_request
110
110
  log "SOAP request: #{@soap.endpoint}"
111
- log headers.merge(soap_headers).map { |key, value| "#{key}: #{value}" }.join(", ")
111
+ log soap_headers.merge(headers).map { |key, value| "#{key}: #{value}" }.join(", ")
112
112
  log @soap.to_xml
113
113
  end
114
114
 
@@ -122,10 +122,10 @@ module Savon
122
122
  # to an optional block.
123
123
  def request(type)
124
124
  request = case type
125
- when :wsdl then Net::HTTP::Get.new @endpoint.to_s
126
- when :soap then Net::HTTP::Post.new @soap.endpoint.to_s, headers.merge(soap_headers)
125
+ when :wsdl then Net::HTTP::Get.new @endpoint.request_uri
126
+ when :soap then Net::HTTP::Post.new @soap.endpoint.request_uri, soap_headers.merge(headers)
127
127
  end
128
- request.basic_auth *@basic_auth if @basic_auth
128
+ request.basic_auth(*@basic_auth) if @basic_auth
129
129
  yield request if block_given?
130
130
  request
131
131
  end
@@ -119,7 +119,7 @@ module Savon
119
119
  def to_xml
120
120
  unless @xml_body
121
121
  @xml_body = @builder.env :Envelope, all_namespaces do |xml|
122
- xml_header xml
122
+ xml.env(:Header) { xml << all_header } unless all_header.empty?
123
123
  xml_body xml
124
124
  end
125
125
  end
@@ -128,20 +128,19 @@ module Savon
128
128
 
129
129
  private
130
130
 
131
- # Adds a SOAP XML header to a given +xml+ Object.
132
- def xml_header(xml)
133
- xml.env(:Header) do
134
- xml << all_header + wsse_header
135
- end
136
- end
137
-
138
131
  # Returns a String containing the global and per request header.
139
132
  def all_header
140
133
  if self.class.header.kind_of?(Hash) && header.kind_of?(Hash)
141
- self.class.header.merge(header).to_soap_xml
134
+ custom_header = self.class.header.merge(header).to_soap_xml
142
135
  else
143
- self.class.header.to_s + header.to_s
136
+ custom_header = self.class.header.to_s + header.to_s
144
137
  end
138
+ custom_header + wsse_header
139
+ end
140
+
141
+ # Returns the WSSE header or an empty String in case WSSE was not set.
142
+ def wsse_header
143
+ @wsse.respond_to?(:header) ? @wsse.header : ""
145
144
  end
146
145
 
147
146
  # Adds a SOAP XML body to a given +xml+ Object.
@@ -162,15 +161,10 @@ module Savon
162
161
  # Defaults to use the name of the SOAP action and may be an empty Array
163
162
  # in case the specified SOAP input seems invalid.
164
163
  def input_array
165
- return [input.to_sym] unless input.blank?
164
+ return input.map { |i| i.is_a?(Hash) ? i : i.to_sym } unless input.blank?
166
165
  return [action.to_sym] unless action.blank?
167
166
  []
168
167
  end
169
168
 
170
- # Returns the WSSE header or an empty String in case WSSE was not set.
171
- def wsse_header
172
- @wsse.respond_to?(:header) ? @wsse.header : ""
173
- end
174
-
175
169
  end
176
170
  end
@@ -62,61 +62,4 @@ module Savon
62
62
  end
63
63
 
64
64
  end
65
-
66
- # Savon::WSDLStream
67
- #
68
- # Stream listener for parsing the WSDL document.
69
- class WSDLStream
70
-
71
- # The main sections of a WSDL document.
72
- Sections = %w(definitions types message portType binding service)
73
-
74
- def initialize
75
- @depth, @operations = 0, {}
76
- end
77
-
78
- # Returns the namespace URI.
79
- attr_reader :namespace_uri
80
-
81
- # Returns the SOAP operations.
82
- attr_reader :operations
83
-
84
- # Returns the SOAP endpoint.
85
- attr_reader :soap_endpoint
86
-
87
- # Hook method called when the stream parser encounters a starting tag.
88
- def tag_start(tag, attrs)
89
- @depth += 1
90
- tag = tag.strip_namespace
91
-
92
- @section = tag.to_sym if @depth <= 2 && Sections.include?(tag)
93
- @namespace_uri ||= attrs["targetNamespace"] if @section == :definitions
94
- @soap_endpoint ||= URI(attrs["location"]) if @section == :service && tag == "address"
95
-
96
- operation_from tag, attrs if @section == :binding && tag == "operation"
97
- end
98
-
99
- # Hook method called when the stream parser encounters a closing tag.
100
- def tag_end(tag)
101
- @depth -= 1
102
- end
103
-
104
- # Stores available operations from a given tag +name+ and +attrs+.
105
- def operation_from(tag, attrs)
106
- @input = attrs["name"] if attrs["name"]
107
-
108
- if attrs["soapAction"]
109
- @action = !attrs["soapAction"].blank? ? attrs["soapAction"] : @input
110
- @input = @action.split("/").last if !@input || @input.empty?
111
-
112
- @operations[@input.snakecase.to_sym] = { :action => @action, :input => @input }
113
- @input, @action = nil, nil
114
- end
115
- end
116
-
117
- # Catches calls to unimplemented hook methods.
118
- def method_missing(method, *args)
119
- end
120
-
121
- end
122
65
  end
@@ -0,0 +1,88 @@
1
+ module Savon
2
+
3
+ # Savon::WSDLStream
4
+ #
5
+ # Stream listener for parsing the WSDL document.
6
+ class WSDLStream
7
+
8
+ # The main sections of a WSDL document.
9
+ Sections = %w(definitions types message portType binding service)
10
+
11
+ def initialize
12
+ @path, @operations = [], {}
13
+ @namespaces = {}
14
+ end
15
+
16
+ # Returns the namespace URI.
17
+ attr_reader :namespace_uri
18
+
19
+ # Returns the SOAP operations.
20
+ attr_reader :operations
21
+
22
+ # Returns the SOAP endpoint.
23
+ attr_reader :soap_endpoint
24
+
25
+ # Hook method called when the stream parser encounters a starting tag.
26
+ def tag_start(tag, attrs)
27
+ # read xml namespaces if root element
28
+ read_namespaces(attrs) if @path.empty?
29
+
30
+ tag,namespace = tag.split(":").reverse
31
+ @path << tag
32
+
33
+ if @section == :binding && tag == "binding"
34
+ # ensure that we are in an wsdl/soap namespace
35
+ @section = nil unless @namespaces[namespace] == "http://schemas.xmlsoap.org/wsdl/soap/"
36
+ end
37
+
38
+ @section = tag.to_sym if Sections.include?(tag) && depth <= 2
39
+
40
+ @namespace_uri ||= attrs["targetNamespace"] if @section == :definitions
41
+ @soap_endpoint ||= URI(attrs["location"]) if @section == :service && tag == "address"
42
+
43
+ operation_from tag, attrs if @section == :binding && tag == "operation"
44
+ end
45
+
46
+ # Returns our current depth in the WSDL document.
47
+ def depth
48
+ @path.size
49
+ end
50
+
51
+ # Reads namespace definitions from a given +attrs+ Hash.
52
+ def read_namespaces(attrs)
53
+ attrs.each do |key, value|
54
+ @namespaces[key.split(":").last] = value if key.start_with? "xmlns:"
55
+ end
56
+ end
57
+
58
+ # Hook method called when the stream parser encounters a closing tag.
59
+ def tag_end(tag)
60
+ @path.pop
61
+
62
+ if @section == :binding && @input && tag.strip_namespace == "operation"
63
+ # no soapAction attribute found till now
64
+ operation_from tag, "soapAction" => @input
65
+ end
66
+
67
+ end
68
+
69
+ # Stores available operations from a given tag +name+ and +attrs+.
70
+ def operation_from(tag, attrs)
71
+ @input = attrs["name"] if attrs["name"]
72
+
73
+ if attrs["soapAction"]
74
+ @action = !attrs["soapAction"].blank? ? attrs["soapAction"] : @input
75
+ @input = @action.split("/").last if !@input || @input.empty?
76
+
77
+ @operations[@input.snakecase.to_sym] = { :action => @action, :input => @input }
78
+ @input, @action = nil, nil
79
+ @input = nil
80
+ end
81
+ end
82
+
83
+ # Catches calls to unimplemented hook methods.
84
+ def method_missing(method, *args)
85
+ end
86
+
87
+ end
88
+ end
@@ -5,6 +5,7 @@ class EndpointHelper
5
5
  case type
6
6
  when :no_namespace then "http://nons.example.com/Service?wsdl"
7
7
  when :namespaced_actions then "http://nsactions.example.com/Service?wsdl"
8
+ when :geotrust then "https://test-api.geotrust.com/webtrust/query.jws?WSDL"
8
9
  else soap_endpoint(type)
9
10
  end
10
11
  end
@@ -0,0 +1,156 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <s0:definitions name="queryDefinitions" targetNamespace="http://api.geotrust.com/webtrust/query" xmlns="" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://api.geotrust.com/webtrust/query" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s3="http://www.openuri.org/2006/12/wsdl/upgradedJWS">
3
+ <s0:types>
4
+ <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://api.geotrust.com/webtrust/query" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://api.geotrust.com/webtrust/query" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s3="http://www.openuri.org/2006/12/wsdl/upgradedJWS" xmlns:xs="http://www.w3.org/2001/XMLSchema">
5
+ <xs:complexType name="GetQuickApproverListInput">
6
+ <xs:sequence>
7
+ <xs:element minOccurs="0" name="QueryRequestHeader" type="quer:queryRequestHeader" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
8
+ <xs:element minOccurs="0" name="Domain" type="xs:string"/>
9
+ <xs:element minOccurs="0" name="IncludeUserAgreement" type="quer:includeUserAgreement" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
10
+ </xs:sequence>
11
+ </xs:complexType>
12
+ <xs:complexType name="queryRequestHeader">
13
+ <xs:sequence>
14
+ <xs:element minOccurs="0" name="PartnerCode" type="xs:string"/>
15
+ <xs:element minOccurs="0" name="AuthToken" type="quer:authToken" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
16
+ <xs:element minOccurs="0" name="ReplayToken" type="xs:string"/>
17
+ <xs:element minOccurs="0" name="UseReplayToken" type="xs:boolean"/>
18
+ </xs:sequence>
19
+ </xs:complexType>
20
+ <xs:complexType name="authToken">
21
+ <xs:sequence>
22
+ <xs:element minOccurs="0" name="UserName" type="xs:string"/>
23
+ <xs:element minOccurs="0" name="Password" type="xs:string"/>
24
+ </xs:sequence>
25
+ </xs:complexType>
26
+ <xs:complexType name="includeUserAgreement">
27
+ <xs:sequence>
28
+ <xs:element minOccurs="0" name="UserAgreementProductCode" type="xs:string"/>
29
+ </xs:sequence>
30
+ </xs:complexType>
31
+ <xs:complexType name="GetUserAgreementInput">
32
+ <xs:sequence>
33
+ <xs:element minOccurs="0" name="QueryRequestHeader" type="quer:queryRequestHeader" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
34
+ <xs:element minOccurs="0" name="UserAgreementProductCode" type="xs:string"/>
35
+ </xs:sequence>
36
+ </xs:complexType>
37
+ <xs:complexType name="GetQuickApproverListOutput">
38
+ <xs:sequence>
39
+ <xs:element minOccurs="0" name="QueryResponseHeader" type="quer:queryResponseHeader" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
40
+ <xs:element minOccurs="0" name="ApproverList" type="quer:ArrayOfApprover" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
41
+ <xs:element minOccurs="0" name="UserAgreement" type="xs:string"/>
42
+ </xs:sequence>
43
+ </xs:complexType>
44
+ <xs:complexType name="queryResponseHeader">
45
+ <xs:sequence>
46
+ <xs:element name="SuccessCode" type="xs:int"/>
47
+ <xs:element minOccurs="0" name="Errors" type="quer:ArrayOfError" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
48
+ <xs:element minOccurs="0" name="Timestamp" type="xs:dateTime"/>
49
+ <xs:element name="ReturnCount" type="xs:int"/>
50
+ </xs:sequence>
51
+ </xs:complexType>
52
+ <xs:complexType name="Error">
53
+ <xs:sequence>
54
+ <xs:element name="ErrorCode" type="xs:int"/>
55
+ <xs:element minOccurs="0" name="ErrorField" type="xs:string"/>
56
+ <xs:element minOccurs="0" name="ErrorMessage" type="xs:string"/>
57
+ </xs:sequence>
58
+ </xs:complexType>
59
+ <xs:complexType name="ArrayOfError">
60
+ <xs:sequence>
61
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="Error" type="quer:Error" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
62
+ </xs:sequence>
63
+ </xs:complexType>
64
+ <xs:element name="ArrayOfError" type="quer:ArrayOfError" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
65
+ <xs:complexType name="Approver">
66
+ <xs:sequence>
67
+ <xs:element minOccurs="0" name="ApproverType" type="xs:string"/>
68
+ <xs:element minOccurs="0" name="ApproverEmail" type="xs:string"/>
69
+ </xs:sequence>
70
+ </xs:complexType>
71
+ <xs:complexType name="ArrayOfApprover">
72
+ <xs:sequence>
73
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="Approver" type="quer:Approver" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
74
+ </xs:sequence>
75
+ </xs:complexType>
76
+ <xs:element name="ArrayOfApprover" type="quer:ArrayOfApprover" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
77
+ <xs:complexType name="ArrayOfString">
78
+ <xs:sequence>
79
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="String" type="xs:string"/>
80
+ </xs:sequence>
81
+ </xs:complexType>
82
+ <xs:element name="ArrayOfString" type="quer:ArrayOfString" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
83
+ <xs:element name="GetQuickApproverList">
84
+ <xs:complexType>
85
+ <xs:sequence>
86
+ <xs:element minOccurs="0" name="Request" type="quer:GetQuickApproverListInput" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
87
+ </xs:sequence>
88
+ </xs:complexType>
89
+ </xs:element>
90
+ <xs:element name="GetQuickApproverListResponse">
91
+ <xs:complexType>
92
+ <xs:sequence>
93
+ <xs:element minOccurs="0" name="GetQuickApproverListResult" type="quer:GetQuickApproverListOutput" xmlns:quer="http://api.geotrust.com/webtrust/query"/>
94
+ </xs:sequence>
95
+ </xs:complexType>
96
+ </xs:element>
97
+ <xs:element name="hello">
98
+ <xs:complexType>
99
+ <xs:sequence>
100
+ <xs:element minOccurs="0" name="Input" type="xs:string"/>
101
+ </xs:sequence>
102
+ </xs:complexType>
103
+ </xs:element>
104
+ <xs:element name="helloResponse">
105
+ <xs:complexType>
106
+ <xs:sequence>
107
+ <xs:element minOccurs="0" name="helloResult" type="xs:string"/>
108
+ </xs:sequence>
109
+ </xs:complexType>
110
+ </xs:element>
111
+ </xs:schema>
112
+ </s0:types>
113
+ <s0:message name="hello">
114
+ <s0:part element="s1:hello" name="parameters"/>
115
+ </s0:message>
116
+ <s0:message name="helloResponse">
117
+ <s0:part element="s1:helloResponse" name="helloResultPart"/>
118
+ </s0:message>
119
+ <s0:portType name="querySoap">
120
+ <s0:operation name="GetQuickApproverList" parameterOrder="parameters">
121
+ <s0:input message="s1:GetQuickApproverList"/>
122
+ <s0:output message="s1:GetQuickApproverListResponse"/>
123
+ </s0:operation>
124
+ <s0:operation name="hello" parameterOrder="parameters">
125
+ <s0:input message="s1:hello"/>
126
+ <s0:output message="s1:helloResponse"/>
127
+ </s0:operation>
128
+ </s0:portType>
129
+ <s0:binding name="querySoapBinding" type="s1:querySoap">
130
+ <s2:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
131
+ <s0:operation name="GetQuickApproverList">
132
+ <s2:operation style="document"/>
133
+ <s0:input>
134
+ <s2:body parts="parameters" use="literal"/>
135
+ </s0:input>
136
+ <s0:output>
137
+ <s2:body parts="GetQuickApproverListResultPart" use="literal"/>
138
+ </s0:output>
139
+ </s0:operation>
140
+ <s0:operation name="hello">
141
+ <s2:operation style="document"/>
142
+ <s0:input>
143
+ <s2:body parts="parameters" use="literal"/>
144
+ </s0:input>
145
+ <s0:output>
146
+ <s2:body parts="helloResultPart" use="literal"/>
147
+ </s0:output>
148
+ </s0:operation>
149
+ </s0:binding>
150
+ <s0:service name="query">
151
+ <s3:upgraded81/>
152
+ <s0:port binding="s1:querySoapBinding" name="querySoap">
153
+ <s2:address location="https://test-api.geotrust.com:443/webtrust/query.jws"/>
154
+ </s0:port>
155
+ </s0:service>
156
+ </s0:definitions>
@@ -21,3 +21,6 @@ FakeWeb.register_uri :get, EndpointHelper.wsdl_endpoint(:no_namespace), :body =>
21
21
 
22
22
  # WSDL request returning a WSDL document with namespaced SOAP actions.
23
23
  FakeWeb.register_uri :get, EndpointHelper.wsdl_endpoint(:namespaced_actions), :body => WSDLFixture.namespaced_actions
24
+
25
+ # WSDL request returning a WSDL document with geotrust SOAP actions.
26
+ FakeWeb.register_uri :get, EndpointHelper.wsdl_endpoint(:geotrust), :body => WSDLFixture.geotrust
@@ -5,7 +5,7 @@ describe DateTime do
5
5
  describe "to_soap_value" do
6
6
  it "returns an xs:dateTime compliant String" do
7
7
  DateTime.new(2012, 03, 22, 16, 22, 33).to_soap_value.
8
- should == "2012-03-22T16:22:33"
8
+ should == "2012-03-22T16:22:33Z"
9
9
  end
10
10
  end
11
11
 
@@ -53,7 +53,7 @@ describe Hash do
53
53
 
54
54
  it "converts DateTime objects to xs:dateTime compliant Strings" do
55
55
  { :before => DateTime.new(2012, 03, 22, 16, 22, 33) }.to_soap_xml.
56
- should == "<before>" << "2012-03-22T16:22:33" << "</before>"
56
+ should == "<before>" << "2012-03-22T16:22:33Z" << "</before>"
57
57
  end
58
58
 
59
59
  it "converts Objects responding to to_datetime to xs:dateTime compliant Strings" do
@@ -63,7 +63,7 @@ describe Hash do
63
63
  end
64
64
 
65
65
  { :before => singleton }.to_soap_xml.
66
- should == "<before>" << "2012-03-22T16:22:33" << "</before>"
66
+ should == "<before>" << "2012-03-22T16:22:33Z" << "</before>"
67
67
  end
68
68
 
69
69
  it "calls to_s on Strings even if they respond to to_datetime" do
@@ -29,7 +29,7 @@ describe Object do
29
29
  DateTime.new(2012, 03, 22, 16, 22, 33)
30
30
  end
31
31
 
32
- singleton.to_soap_value.should == "2012-03-22T16:22:33"
32
+ singleton.to_soap_value.should == "2012-03-22T16:22:33Z"
33
33
  end
34
34
 
35
35
  it "calls to_s unless the Object responds to to_datetime" do
@@ -4,10 +4,8 @@ describe Savon::Request do
4
4
  before { @request = Savon::Request.new EndpointHelper.wsdl_endpoint }
5
5
 
6
6
  it "contains the ContentType for each supported SOAP version" do
7
- Savon::SOAPVersions.each do |soap_version|
8
- Savon::Request::ContentType[soap_version].should be_a(String)
9
- Savon::Request::ContentType[soap_version].should_not be_empty
10
- end
7
+ content_type = { 1 => "text/xml;charset=UTF-8", 2 => "application/soap+xml;charset=UTF-8" }
8
+ content_type.each { |version, type| Savon::Request::ContentType[version].should == type }
11
9
  end
12
10
 
13
11
  # defaults to log request and response. disabled for spec execution
@@ -86,4 +84,9 @@ describe Savon::Request do
86
84
  soap_response.body.should == ResponseFixture.authentication
87
85
  end
88
86
 
87
+ it "should not include host when creating HTTP requests" do
88
+ request = @request.send(:request, :wsdl)
89
+ request.path.should_not include("example.com")
90
+ end
91
+
89
92
  end
@@ -12,7 +12,7 @@ describe Savon do
12
12
  Savon::SOAPDateTimeFormat.should_not be_empty
13
13
 
14
14
  DateTime.new(2012, 03, 22, 16, 22, 33).strftime(Savon::SOAPDateTimeFormat).
15
- should == "2012-03-22T16:22:33"
15
+ should == "2012-03-22T16:22:33Z"
16
16
  end
17
17
 
18
18
  it "contains a Regexp matching the xs:dateTime format" do
@@ -43,7 +43,7 @@ describe Savon::SOAP do
43
43
  end
44
44
 
45
45
  it "has a setter for the SOAP input" do
46
- @soap.input = "FindUserRequest"
46
+ @soap.input = "FindUserRequest", { "username" => "auser", "anotherAttr" => "someVal" }
47
47
  end
48
48
 
49
49
  it "has both getter and setter for global SOAP headers" do
@@ -124,9 +124,21 @@ describe Savon::SOAP do
124
124
  @soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.auth.order.example.com/"
125
125
  @soap.body = { :id => 666 }
126
126
 
127
- @soap.to_xml.should include('xmlns:wsdl="http://v1_0.ws.auth.order.example.com/"')
128
- @soap.to_xml.should include('xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"')
129
- @soap.to_xml.should include('<wsdl:authenticate><id>666</id></wsdl:authenticate>')
127
+ xml = @soap.to_xml
128
+ xml.should include('xmlns:wsdl="http://v1_0.ws.auth.order.example.com/"')
129
+ xml.should include('xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"')
130
+ xml.should include('<wsdl:authenticate><id>666</id></wsdl:authenticate>')
131
+ end
132
+
133
+ it "does not include an empty header tag" do
134
+ @soap.to_xml.should_not include('env:Header')
135
+ end
136
+
137
+ it "returns the appropriate XML for a SOAP Body's root node when parameters are present" do
138
+ @soap.input = "authenticate", { "protocol" => "tls", "version" => "1.2" }
139
+ @soap.body = { :id => 666 }
140
+
141
+ @soap.to_xml.should include('<wsdl:authenticate protocol="tls" version="1.2"><id>666</id></wsdl:authenticate>')
130
142
  end
131
143
 
132
144
  it "caches the XML, returning the same Object every time" do
@@ -76,6 +76,24 @@ describe Savon::WSDL do
76
76
  end
77
77
  end
78
78
 
79
+ describe "a WSDL document from geotrust" do
80
+ before { @wsdl = new_wsdl :geotrust }
81
+
82
+ it "returns the namespace URI" do
83
+ @wsdl.namespace_uri.should == WSDLFixture.geotrust(:namespace_uri)
84
+ end
85
+
86
+ it "returns an Array of available SOAP actions" do
87
+ WSDLFixture.geotrust(:operations).keys.each do |soap_action|
88
+ @wsdl.soap_actions.should include(soap_action)
89
+ end
90
+ end
91
+
92
+ it "returns a Hash of SOAP operations" do
93
+ @wsdl.operations.should == WSDLFixture.geotrust(:operations)
94
+ end
95
+ end
96
+
79
97
  def new_wsdl(fixture = nil)
80
98
  endpoint = fixture ? EndpointHelper.wsdl_endpoint(fixture) : EndpointHelper.wsdl_endpoint
81
99
  Savon::WSDL.new Savon::Request.new(endpoint)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-17 00:00:00 +01:00
12
+ date: 2010-01-31 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,7 @@ files:
87
87
  - lib/savon/response.rb
88
88
  - lib/savon/soap.rb
89
89
  - lib/savon/wsdl.rb
90
+ - lib/savon/wsdl_stream.rb
90
91
  - lib/savon/wsse.rb
91
92
  - lib/savon.rb
92
93
  - spec/basic_spec_helper.rb
@@ -116,6 +117,7 @@ files:
116
117
  - spec/fixtures/response/xml/soap_fault.xml
117
118
  - spec/fixtures/response/xml/soap_fault12.xml
118
119
  - spec/fixtures/wsdl/xml/authentication.xml
120
+ - spec/fixtures/wsdl/xml/geotrust.xml
119
121
  - spec/fixtures/wsdl/xml/namespaced_actions.xml
120
122
  - spec/fixtures/wsdl/xml/no_namespace.xml
121
123
  has_rdoc: true