Changeset 1665
- Timestamp:
- 11/08/05 23:57:33 (3 years ago)
- Files:
-
- trunk/lib/soap/rpc/proxy.rb (modified) (2 diffs)
- trunk/lib/soap/streamHandler.rb (modified) (3 diffs)
- trunk/lib/wsdl/xmlSchema/complexExtension.rb (modified) (1 diff)
- trunk/sample/wsdl/PayPalSvc (added)
- trunk/sample/wsdl/PayPalSvc/client.rb (added)
- trunk/test/soap/test_streamhandler.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/soap/rpc/proxy.rb
r1624 r1665 42 42 @soapaction = soapaction 43 43 @options = options 44 @ streamhandler = HTTPStreamHandler.new(45 @options["protocol.http"] ||= ::SOAP::Property.new)44 @protocol_option = options["protocol"] ||= ::SOAP::Property.new 45 initialize_streamhandler(@protocol_option) 46 46 @operation = {} 47 47 @mandatorycharset = nil … … 184 184 private 185 185 186 def initialize_streamhandler(options) 187 value = options["streamhandler"] 188 if value and !value.empty? 189 factory = Property::Util.const_from_name(value) 190 else 191 factory = HTTPStreamHandler 192 end 193 @streamhandler = factory.create(options) 194 options.add_hook("streamhandler") do |key, value| 195 @streamhandler.reset 196 if value.respond_to?(:create) 197 factory = value 198 elsif value and !value.to_str.empty? 199 factory = Property::Util.const_from_name(value.to_str) 200 else 201 factory = HTTPStreamHandler 202 end 203 options.unlock(true) 204 @streamhandler = factory.create(options) 205 end 206 end 207 186 208 def set_envelopenamespace(env, namespace) 187 209 env.elename = XSD::QName.new(namespace, env.elename.name) trunk/lib/soap/streamHandler.rb
r1614 r1665 53 53 "#{ MediaType }; charset=#{ charset }" 54 54 end 55 56 def send(endpoint_url, conn_data, soapaction = nil, charset = nil) 57 # send a ConnectionData to specified endpoint_url. 58 # return value is a ConnectionData with receive_* property filled. 59 # You can fill values of given conn_data and return it. 60 end 61 62 def reset(endpoint_url = nil) 63 # for initializing connection status if needed. 64 # return value is not expected. 65 end 66 67 def set_wiredump_file_base(wiredump_file_base) 68 # for logging. return value is not expected. 69 # Override it when you want. 70 raise NotImplementedError 71 end 72 73 def test_loopback_response 74 # for loopback testing. see HTTPStreamHandler for more detail. 75 # return value is an Array of loopback responses. 76 # Override it when you want. 77 raise NotImplementedError 78 end 55 79 end 56 80 … … 80 104 81 105 MAX_RETRY_COUNT = 10 # [times] 106 107 def self.create(options) 108 new(options) 109 end 82 110 83 111 def initialize(options) … … 122 150 123 151 def set_options 124 HTTPConfigLoader.set_options(@client, @options) 125 @charset = @options["charset"] || XSD::Charset.xml_encoding_label 126 @options.add_hook("charset") do |key, value| 152 @options["http"] ||= ::SOAP::Property.new 153 HTTPConfigLoader.set_options(@client, @options["http"]) 154 @charset = @options["http.charset"] || XSD::Charset.xml_encoding_label 155 @options.add_hook("http.charset") do |key, value| 127 156 @charset = value 128 157 end 129 @wiredump_dev = @options[" wiredump_dev"]130 @options.add_hook(" wiredump_dev") do |key, value|158 @wiredump_dev = @options["http.wiredump_dev"] 159 @options.add_hook("http.wiredump_dev") do |key, value| 131 160 @wiredump_dev = value 132 161 @client.debug_dev = @wiredump_dev 133 162 end 134 set_cookie_store_file(@options[" cookie_store_file"])135 @options.add_hook(" cookie_store_file") do |key, value|163 set_cookie_store_file(@options["http.cookie_store_file"]) 164 @options.add_hook("http.cookie_store_file") do |key, value| 136 165 set_cookie_store_file(value) 137 166 end 138 ssl_config = @options[" ssl_config"]139 basic_auth = @options[" basic_auth"]140 @options .lock(true)167 ssl_config = @options["http.ssl_config"] 168 basic_auth = @options["http.basic_auth"] 169 @options["http"].lock(true) 141 170 ssl_config.unlock 142 171 basic_auth.unlock trunk/lib/wsdl/xmlSchema/complexExtension.rb
r1653 r1665 88 88 def basetype 89 89 @basetype ||= root.collect_complextypes[@base] 90 unless @basetype 91 RuntimeError.new("base type definition not found: #{@base}") 92 end 93 @basetype 90 94 end 91 95 end trunk/test/soap/test_streamhandler.rb
r1615 r1665 204 204 assert_equal("text/xml; charset=iso-8859-3", h["content-type"]) 205 205 end 206 207 def test_custom_streamhandler 208 @client.options["protocol.streamhandler"] = MyStreamHandler 209 assert_equal("hello", @client.do_server_proc) 210 @client.options["protocol.streamhandler"] = ::SOAP::HTTPStreamHandler 211 assert_nil(@client.do_server_proc) 212 @client.options["protocol.streamhandler"] = MyStreamHandler 213 assert_equal("hello", @client.do_server_proc) 214 @client.options["protocol.streamhandler"] = ::SOAP::HTTPStreamHandler 215 assert_nil(@client.do_server_proc) 216 end 217 218 class MyStreamHandler < SOAP::StreamHandler 219 def self.create(options) 220 new 221 end 222 223 def send(endpoint_url, conn_data, soapaction = nil, charset = nil) 224 conn_data.receive_string = %q[<?xml version="1.0" encoding="utf-8" ?> 225 <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 226 <env:Body> 227 <n1:do_server_proc xmlns:n1="urn:foo" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 228 <return xsi:type="xsd:string">hello</return> 229 </n1:do_server_proc> 230 </env:Body> 231 </env:Envelope>] 232 conn_data 233 end 234 235 def reset(endpoint_url = nil) 236 # nothing to do 237 end 238 end 206 239 end 207 240