* lib/soap/**/*.rb, lib/wsdl/**/*.rb, lib/xsd/**/*.rb: changed license; GPL2 -> Ruby's.
* lib/soap/rpc/driver.rb, lib/soap/wsdlDriver.rb, lib/soap/streamHandler.rb: add interface to streamhandler.
* lib/soap/marshal.rb: raise error if parse fails.
* lib/soap/netHttpClient.rb: add https support. Patched by Oliver M. Bolzer.
* lib/soap/netHttpClient.rb: dump HTTP response message body by itself.
* lib/soap/rpc/driver.rb, lib/soap/rpc/proxy.rb, lib/soap/wsdlDriver.rb: add driver#mandatorycharset interface to foce using charset for parsing response from buggy server.
* lib/soap/encodingstyle/soapHandler.rb: support Apache Axis's half typed multi-ref array.
* lib/soap/mapping/factory.rb, lib/soap/mapping/registry.rb: map SOAPStruct which has multi-accessors which name are the same, to an array.
* lib/soap/rpc/element.rb: fixed illegal parameter order.
* lib/soap/rpc/element.rb: element name of response message could have the name other than 'return'.
* lib/wsdl/operation.rb, lib/wsdl/operationBinding.rb, lib/wsdl/soap/classDefCreator.rb, lib/wsdl/soap/methodDefCreator.rb, lib/wsdl/soap/methodDefCreatorSupport.rb: WSDL/1.1 allows plural fault definition in a operation. [ruby-talk:84948]
* test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb: add test for above fix.
* lib/wsdl/soap/complexType.rb: support WSDL array definition with maxOccures="unbound".
* lib/xsd/charset.rb: use cp932 under emx. Patched by Siena. / SHINAGAWA, Norihide in [ruby-dev:21972]
* lib/xsd/xmlparser/parser.rb: set @charset nil by default. Nil means 'follow encoding declaration in XML'.
* sample/soap/digraph.rb, sample/wsdl/amazon/wsdlDriver.rb, sample/wsdl/googleSearch/sampleClient.rb, sample/wsdl/googleSearch/wsdlDriver.rb, test/wsdl/test_emptycomplextype.rb, test/wsdl/marshal/test_wsdlmarshal.rb, test/xsd/test_xmlschemaparser.rb: use File.open(...) { |f| f.read } instead of File.open(...).read. [ruby-dev:21964]
* test/wsdl/emptycomplextype.wsdl, test/wsdl/test_emptycomplextype.rb: simplify the test case.
* test/wsdl/axisArray/*: add tests for axis's array encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-25 02:31:33 -05:00
|
|
|
# SOAP4R - RPC Routing library
|
|
|
|
# Copyright (C) 2001, 2002 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
|
|
|
|
|
|
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
|
|
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
|
|
|
# either the dual license version in 2003, or any later version.
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
require 'soap/soap'
|
|
|
|
require 'soap/processor'
|
|
|
|
require 'soap/mapping'
|
2004-12-20 08:50:15 -05:00
|
|
|
require 'soap/mapping/wsdlliteralregistry'
|
2003-09-24 11:18:44 -04:00
|
|
|
require 'soap/rpc/rpc'
|
|
|
|
require 'soap/rpc/element'
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
require 'soap/streamHandler'
|
|
|
|
require 'soap/mimemessage'
|
2004-07-03 09:33:20 -04:00
|
|
|
require 'soap/header/handlerset'
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
module SOAP
|
|
|
|
module RPC
|
|
|
|
|
|
|
|
|
|
|
|
class Router
|
|
|
|
include SOAP
|
|
|
|
|
|
|
|
attr_reader :actor
|
|
|
|
attr_accessor :allow_unqualified_element
|
|
|
|
attr_accessor :default_encodingstyle
|
|
|
|
attr_accessor :mapping_registry
|
2004-12-20 08:50:15 -05:00
|
|
|
attr_accessor :literal_mapping_registry
|
2004-07-03 09:33:20 -04:00
|
|
|
attr_reader :headerhandler
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
def initialize(actor)
|
|
|
|
@actor = actor
|
|
|
|
@allow_unqualified_element = false
|
|
|
|
@default_encodingstyle = nil
|
|
|
|
@mapping_registry = nil
|
2004-07-03 09:33:20 -04:00
|
|
|
@headerhandler = Header::HandlerSet.new
|
2004-12-20 08:50:15 -05:00
|
|
|
@literal_mapping_registry = ::SOAP::Mapping::WSDLLiteralRegistry.new
|
|
|
|
@operation = {}
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def add_rpc_method(receiver, qname, soapaction, name, param_def, opt = {})
|
|
|
|
opt[:request_style] ||= :rpc
|
|
|
|
opt[:response_style] ||= :rpc
|
|
|
|
opt[:request_use] ||= :encoded
|
|
|
|
opt[:response_use] ||= :encoded
|
|
|
|
add_operation(qname, soapaction, receiver, name, param_def, opt)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def add_document_method(receiver, qname, soapaction, name, param_def, opt = {})
|
|
|
|
opt[:request_style] ||= :document
|
|
|
|
opt[:response_style] ||= :document
|
|
|
|
opt[:request_use] ||= :encoded
|
|
|
|
opt[:response_use] ||= :encoded
|
|
|
|
if opt[:request_style] == :document
|
|
|
|
inputdef = param_def.find { |inout, paramname, typeinfo| inout == "input" }
|
|
|
|
klass, nsdef, namedef = inputdef[2]
|
|
|
|
qname = ::XSD::QName.new(nsdef, namedef)
|
|
|
|
end
|
|
|
|
add_operation(qname, soapaction, receiver, name, param_def, opt)
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_operation(qname, soapaction, receiver, name, param_def, opt)
|
|
|
|
@operation[fqname(qname)] = Operation.new(qname, soapaction, receiver,
|
|
|
|
name, param_def, opt)
|
|
|
|
end
|
|
|
|
|
|
|
|
# add_method is for shortcut of typical use="encoded" method definition.
|
|
|
|
alias add_method add_rpc_method
|
|
|
|
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
def route(conn_data)
|
|
|
|
soap_response = nil
|
2003-09-24 11:18:44 -04:00
|
|
|
begin
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
env = unmarshal(conn_data)
|
|
|
|
if env.nil?
|
|
|
|
raise ArgumentError.new("Illegal SOAP marshal format.")
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
receive_headers(env.header)
|
2004-12-20 08:50:15 -05:00
|
|
|
request = env.body.request
|
|
|
|
op = @operation[fqname(request.elename)]
|
|
|
|
unless op
|
|
|
|
raise RPCRoutingError.new("Method: #{request.elename} not supported.")
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
soap_response = op.call(request, @mapping_registry, @literal_mapping_registry)
|
2003-09-24 11:18:44 -04:00
|
|
|
rescue Exception
|
|
|
|
soap_response = fault($!)
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
conn_data.is_fault = true
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
marshal(conn_data, op, soap_response)
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
conn_data
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Create fault response string.
|
|
|
|
def create_fault_response(e, charset = nil)
|
|
|
|
header = SOAPHeader.new
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
body = SOAPBody.new(fault(e))
|
|
|
|
env = SOAPEnvelope.new(header, body)
|
2003-09-24 11:18:44 -04:00
|
|
|
opt = options
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
opt[:external_content] = nil
|
2003-09-24 11:18:44 -04:00
|
|
|
opt[:charset] = charset
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
response_string = Processor.marshal(env, opt)
|
|
|
|
conn_data = StreamHandler::ConnectionData.new(response_string)
|
|
|
|
conn_data.is_fault = true
|
|
|
|
if ext = opt[:external_content]
|
|
|
|
mime = MIMEMessage.new
|
|
|
|
ext.each do |k, v|
|
|
|
|
mime.add_attachment(v.data)
|
|
|
|
end
|
|
|
|
mime.add_part(conn_data.send_string + "\r\n")
|
|
|
|
mime.close
|
|
|
|
conn_data.send_string = mime.content_str
|
|
|
|
conn_data.send_contenttype = mime.headers['content-type'].str
|
|
|
|
end
|
|
|
|
conn_data
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def call_headers
|
|
|
|
headers = @headerhandler.on_outbound
|
|
|
|
if headers.empty?
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
h = ::SOAP::SOAPHeader.new
|
|
|
|
headers.each do |header|
|
2004-12-20 08:50:15 -05:00
|
|
|
h.add(header.elename.name, header)
|
|
|
|
end
|
|
|
|
h
|
2004-07-03 09:33:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def receive_headers(headers)
|
|
|
|
@headerhandler.on_inbound(headers) if headers
|
|
|
|
end
|
|
|
|
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
def unmarshal(conn_data)
|
|
|
|
opt = options
|
|
|
|
contenttype = conn_data.receive_contenttype
|
|
|
|
if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
|
|
|
|
opt[:external_content] = {}
|
|
|
|
mime = MIMEMessage.parse("Content-Type: " + contenttype,
|
2004-07-03 09:33:20 -04:00
|
|
|
conn_data.receive_string)
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
mime.parts.each do |part|
|
|
|
|
value = Attachment.new(part.content)
|
|
|
|
value.contentid = part.contentid
|
|
|
|
obj = SOAPAttachment.new(value)
|
|
|
|
opt[:external_content][value.contentid] = obj if value.contentid
|
|
|
|
end
|
|
|
|
opt[:charset] =
|
|
|
|
StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
|
|
|
|
env = Processor.unmarshal(mime.root.content, opt)
|
|
|
|
else
|
|
|
|
opt[:charset] = ::SOAP::StreamHandler.parse_media_type(contenttype)
|
|
|
|
env = Processor.unmarshal(conn_data.receive_string, opt)
|
|
|
|
end
|
|
|
|
charset = opt[:charset]
|
|
|
|
conn_data.send_contenttype = "text/xml; charset=\"#{charset}\""
|
|
|
|
env
|
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def marshal(conn_data, op, soap_response)
|
|
|
|
response_opt = options
|
|
|
|
response_opt[:external_content] = nil
|
|
|
|
if op and !conn_data.is_fault and op.response_use == :document
|
|
|
|
response_opt[:default_encodingstyle] =
|
|
|
|
::SOAP::EncodingStyle::ASPDotNetHandler::Namespace
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
header = call_headers
|
|
|
|
body = SOAPBody.new(soap_response)
|
|
|
|
env = SOAPEnvelope.new(header, body)
|
|
|
|
response_string = Processor.marshal(env, response_opt)
|
|
|
|
conn_data.send_string = response_string
|
|
|
|
if ext = response_opt[:external_content]
|
|
|
|
mime = MIMEMessage.new
|
|
|
|
ext.each do |k, v|
|
|
|
|
mime.add_attachment(v.data)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
mime.add_part(conn_data.send_string + "\r\n")
|
|
|
|
mime.close
|
|
|
|
conn_data.send_string = mime.content_str
|
|
|
|
conn_data.send_contenttype = mime.headers['content-type'].str
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Create fault response.
|
|
|
|
def fault(e)
|
|
|
|
detail = Mapping::SOAPException.new(e)
|
|
|
|
SOAPFault.new(
|
|
|
|
SOAPString.new('Server'),
|
|
|
|
SOAPString.new(e.to_s),
|
|
|
|
SOAPString.new(@actor),
|
|
|
|
Mapping.obj2soap(detail, @mapping_registry))
|
|
|
|
end
|
|
|
|
|
|
|
|
def fqname(qname)
|
|
|
|
"#{ qname.namespace }:#{ qname.name }"
|
|
|
|
end
|
|
|
|
|
|
|
|
def options
|
|
|
|
opt = {}
|
|
|
|
opt[:default_encodingstyle] = @default_encodingstyle
|
|
|
|
if @allow_unqualified_element
|
|
|
|
opt[:allow_unqualified_element] = true
|
|
|
|
end
|
|
|
|
opt
|
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
|
|
|
|
class Operation
|
|
|
|
attr_reader :receiver
|
|
|
|
attr_reader :name
|
|
|
|
attr_reader :soapaction
|
|
|
|
attr_reader :request_style
|
|
|
|
attr_reader :response_style
|
|
|
|
attr_reader :request_use
|
|
|
|
attr_reader :response_use
|
|
|
|
|
|
|
|
def initialize(qname, soapaction, receiver, name, param_def, opt)
|
|
|
|
@soapaction = soapaction
|
|
|
|
@receiver = receiver
|
|
|
|
@name = name
|
|
|
|
@request_style = opt[:request_style]
|
|
|
|
@response_style = opt[:response_style]
|
|
|
|
@request_use = opt[:request_use]
|
|
|
|
@response_use = opt[:response_use]
|
|
|
|
if @response_style == :rpc
|
|
|
|
@rpc_response_factory =
|
|
|
|
RPC::SOAPMethodRequest.new(qname, param_def, @soapaction)
|
|
|
|
else
|
|
|
|
outputdef = param_def.find { |inout, paramname, typeinfo| inout == "output" }
|
|
|
|
klass, nsdef, namedef = outputdef[2]
|
|
|
|
@document_response_qname = ::XSD::QName.new(nsdef, namedef)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(request, mapping_registry, literal_mapping_registry)
|
|
|
|
if @request_style == :rpc
|
|
|
|
param = Mapping.soap2obj(request, mapping_registry)
|
|
|
|
result = rpc_call(request, param)
|
|
|
|
else
|
|
|
|
param = Mapping.soap2obj(request, literal_mapping_registry)
|
|
|
|
result = document_call(request, param)
|
|
|
|
end
|
|
|
|
if @response_style == :rpc
|
|
|
|
rpc_response(result, mapping_registry)
|
|
|
|
else
|
|
|
|
document_response(result, literal_mapping_registry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def rpc_call(request, param)
|
|
|
|
unless request.is_a?(SOAPStruct)
|
|
|
|
raise RPCRoutingError.new("Not an RPC style.")
|
|
|
|
end
|
|
|
|
values = request.collect { |key, value| param[key] }
|
|
|
|
@receiver.method(@name.intern).call(*values)
|
|
|
|
end
|
|
|
|
|
|
|
|
def document_call(request, param)
|
|
|
|
@receiver.method(@name.intern).call(param)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rpc_response(result, mapping_registry)
|
|
|
|
soap_response = @rpc_response_factory.create_method_response
|
|
|
|
if soap_response.have_outparam?
|
|
|
|
unless result.is_a?(Array)
|
|
|
|
raise RPCRoutingError.new("Out parameter was not returned.")
|
|
|
|
end
|
|
|
|
outparams = {}
|
|
|
|
i = 1
|
|
|
|
soap_response.each_param_name('out', 'inout') do |outparam|
|
|
|
|
outparams[outparam] = Mapping.obj2soap(result[i], mapping_registry)
|
|
|
|
i += 1
|
|
|
|
end
|
|
|
|
soap_response.set_outparam(outparams)
|
|
|
|
soap_response.retval = Mapping.obj2soap(result[0], mapping_registry)
|
|
|
|
else
|
|
|
|
soap_response.retval = Mapping.obj2soap(result, mapping_registry)
|
|
|
|
end
|
|
|
|
soap_response
|
|
|
|
end
|
|
|
|
|
|
|
|
def document_response(result, literal_mapping_registry)
|
|
|
|
literal_mapping_registry.obj2soap(result, @document_response_qname)
|
|
|
|
end
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|