Changeset 1825
- Timestamp:
- 06/02/07 10:39:39 (2 years ago)
- Files:
-
- trunk/install.rb (modified) (1 diff)
- trunk/lib/soap/element.rb (modified) (2 diffs)
- trunk/lib/soap/filter (added)
- trunk/lib/soap/filter.rb (added)
- trunk/lib/soap/filter/filterbase.rb (added)
- trunk/lib/soap/filter/filterchain.rb (added)
- trunk/lib/soap/rpc/cgistub.rb (modified) (1 diff)
- trunk/lib/soap/rpc/driver.rb (modified) (1 diff)
- trunk/lib/soap/rpc/element.rb (modified) (1 diff)
- trunk/lib/soap/rpc/httpserver.rb (modified) (1 diff)
- trunk/lib/soap/rpc/proxy.rb (modified) (6 diffs)
- trunk/lib/soap/rpc/router.rb (modified) (10 diffs)
- trunk/test/soap/filter (added)
- trunk/test/soap/filter/test_filter.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/install.rb
r1781 r1825 68 68 install_dir(SRCPATH, 'soap', 'encodingstyle') 69 69 install_dir(SRCPATH, 'soap', 'header') 70 install_dir(SRCPATH, 'soap', 'filter') 70 71 install_dir(SRCPATH, 'wsdl') 71 72 install_dir(SRCPATH, 'wsdl', 'xmlSchema') trunk/lib/soap/element.rb
r1824 r1825 95 95 class SOAPBody < SOAPStruct 96 96 include SOAPEnvelopeElement 97 98 attr_reader :is_fault 97 99 98 100 def initialize(data = nil, is_fault = false) … … 115 117 name = ns.name(@elename) 116 118 generator.encode_tag(name, attrs) 117 if @is_fault 118 yield(@data) 119 else 120 @data.each do |data| 121 yield(data) 122 end 119 @data.each do |data| 120 yield(data) 123 121 end 124 122 generator.encode_tag_end(name, true) trunk/lib/soap/rpc/cgistub.rb
r1824 r1825 149 149 end 150 150 alias add_rpc_headerhandler add_headerhandler 151 152 def filterchain 153 @router.filterchain 154 end 151 155 152 156 # method entry interface trunk/lib/soap/rpc/driver.rb
r1824 r1825 63 63 __attr_proxy :return_response_as_xml, true 64 64 __attr_proxy :headerhandler 65 __attr_proxy :filterchain 65 66 __attr_proxy :streamhandler 66 67 __attr_proxy :test_loopback_response trunk/lib/soap/rpc/element.rb
r1824 r1825 304 304 end 305 305 306 def retval 307 @retval 308 end 309 306 310 def retval=(retval) 307 311 @retval = retval trunk/lib/soap/rpc/httpserver.rb
r1824 r1825 104 104 alias add_rpc_headerhandler add_headerhandler 105 105 106 def filterchain 107 @router.filterchain 108 end 109 106 110 # method entry interface 107 111 trunk/lib/soap/rpc/proxy.rb
r1824 r1825 13 13 require 'soap/rpc/rpc' 14 14 require 'soap/rpc/element' 15 require 'soap/header/handlerset' 16 require 'soap/filter' 15 17 require 'soap/streamHandler' 16 18 require 'soap/mimemessage' … … 33 35 attr_accessor :return_response_as_xml 34 36 attr_reader :headerhandler 37 attr_reader :filterchain 35 38 attr_reader :streamhandler 36 39 … … 55 58 @return_response_as_xml = false 56 59 @headerhandler = Header::HandlerSet.new 60 @filterchain = Filter::FilterChain.new 57 61 @mapping_registry = nil 58 62 @literal_mapping_registry = ::SOAP::Mapping::LiteralRegistry.new … … 249 253 250 254 def marshal(env, opt) 255 @filterchain.each do |filter| 256 env = filter.on_outbound(env, opt) 257 break unless env 258 end 251 259 send_string = Processor.marshal(env, opt) 252 260 StreamHandler::ConnectionData.new(send_string) … … 255 263 def unmarshal(conn_data, opt) 256 264 contenttype = conn_data.receive_contenttype 265 xml = nil 257 266 if /#{MIMEMessage::MultipartContentType}/i =~ contenttype 258 267 opt[:external_content] = {} … … 267 276 opt[:charset] = @mandatorycharset || 268 277 StreamHandler.parse_media_type(mime.root.headers['content-type'].str) 269 env = Processor.unmarshal(mime.root.content, opt) 270 if @return_response_as_xml 271 opt[:response_as_xml] = mime.root.content 272 end 278 xml = mime.root.content 273 279 else 274 280 opt[:charset] = @mandatorycharset || 275 281 ::SOAP::StreamHandler.parse_media_type(contenttype) 276 env = Processor.unmarshal(conn_data.receive_string, opt) 277 if @return_response_as_xml 278 opt[:response_as_xml] = conn_data.receive_string 279 end 282 xml = conn_data.receive_string 283 end 284 @filterchain.reverse_each do |filter| 285 xml = filter.on_inbound(xml, opt) 286 break unless xml 287 end 288 env = Processor.unmarshal(xml, opt) 289 if @return_response_as_xml 290 opt[:response_as_xml] = xml 280 291 end 281 292 unless env.is_a?(::SOAP::SOAPEnvelope) trunk/lib/soap/rpc/router.rb
r1824 r1825 13 13 require 'soap/rpc/rpc' 14 14 require 'soap/rpc/element' 15 require 'soap/header/handlerset' 16 require 'soap/filter' 15 17 require 'soap/streamHandler' 16 18 require 'soap/mimemessage' … … 30 32 attr_accessor :generate_explicit_type 31 33 attr_accessor :external_ces 34 attr_reader :filterchain 32 35 33 36 def initialize(actor) … … 41 44 @operation_by_qname = {} 42 45 @headerhandlerfactory = [] 46 @filterchain = Filter::FilterChain.new 43 47 end 44 48 … … 168 172 op.call(env.body, @mapping_registry, @literal_mapping_registry, 169 173 create_mapping_opt) 174 conn_data.is_fault = true if soap_response.is_a?(SOAPFault) 170 175 default_encodingstyle = op.response_default_encodingstyle 171 176 rescue Exception => e … … 175 180 wsdl_fault_details = op.faults && op.faults[e.class.name] 176 181 soap_response = fault(e, wsdl_fault_details) 182 conn_data.is_fault = true 177 183 default_encodingstyle = nil 178 184 end 179 conn_data.is_fault = true if soap_response.is_a?(SOAPFault)180 185 header = call_headers(headerhandler) 181 186 if op.response_use.nil? … … 184 189 conn_data 185 190 else 186 body = SOAPBody.new(soap_response )191 body = SOAPBody.new(soap_response, conn_data.is_fault) 187 192 env = SOAPEnvelope.new(header, body) 188 193 marshal(conn_data, env, default_encodingstyle) … … 192 197 # Create fault response string. 193 198 def create_fault_response(e) 194 env = SOAPEnvelope.new(SOAPHeader.new, SOAPBody.new(fault(e, nil) ))199 env = SOAPEnvelope.new(SOAPHeader.new, SOAPBody.new(fault(e, nil), true)) 195 200 opt = {} 196 201 opt[:external_content] = nil 202 @filterchain.reverse_each do |filter| 203 env = filter.on_outbound(env, opt) 204 break unless env 205 end 197 206 response_string = Processor.marshal(env, opt) 198 207 conn_data = StreamHandler::ConnectionData.new(response_string) … … 283 292 284 293 def unmarshal(conn_data) 294 xml = nil 285 295 opt = {} 286 296 contenttype = conn_data.receive_contenttype … … 297 307 opt[:charset] = 298 308 StreamHandler.parse_media_type(mime.root.headers['content-type'].str) 299 env = Processor.unmarshal(mime.root.content, opt)309 xml = mime.root.content 300 310 else 301 311 opt[:charset] = ::SOAP::StreamHandler.parse_media_type(contenttype) 302 env = Processor.unmarshal(conn_data.receive_string, opt) 303 end 312 xml = conn_data.receive_string 313 end 314 @filterchain.each do |filter| 315 xml = filter.on_inbound(xml, opt) 316 break unless xml 317 end 318 env = Processor.unmarshal(xml, opt) 304 319 charset = opt[:charset] 305 320 conn_data.send_contenttype = "text/xml; charset=\"#{charset}\"" … … 312 327 opt[:default_encodingstyle] = default_encodingstyle 313 328 opt[:generate_explicit_type] = @generate_explicit_type 329 @filterchain.reverse_each do |filter| 330 env = filter.on_outbound(env, opt) 331 break unless env 332 end 314 333 response_string = Processor.marshal(env, opt) 315 334 conn_data.send_string = response_string