* 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 Proxy library.
|
2004-07-03 09:33:20 -04:00
|
|
|
# Copyright (C) 2000, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
2003-09-24 11:18:44 -04:00
|
|
|
|
* 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
|
|
|
# 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'
|
|
|
|
require 'soap/rpc/rpc'
|
|
|
|
require 'soap/rpc/element'
|
|
|
|
require 'soap/streamHandler'
|
* 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/mimemessage'
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
module SOAP
|
|
|
|
module RPC
|
|
|
|
|
|
|
|
|
|
|
|
class Proxy
|
|
|
|
include SOAP
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
|
|
attr_accessor :soapaction
|
* 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
|
|
|
attr_accessor :mandatorycharset
|
|
|
|
attr_accessor :allow_unqualified_element
|
|
|
|
attr_accessor :default_encodingstyle
|
2004-12-20 08:50:15 -05:00
|
|
|
attr_accessor :generate_explicit_type
|
|
|
|
attr_reader :headerhandler
|
|
|
|
attr_reader :streamhandler
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
attr_accessor :mapping_registry
|
|
|
|
attr_accessor :literal_mapping_registry
|
|
|
|
|
|
|
|
attr_reader :operation
|
|
|
|
|
|
|
|
def initialize(endpoint_url, soapaction, options)
|
|
|
|
@endpoint_url = endpoint_url
|
2003-09-24 11:18:44 -04:00
|
|
|
@soapaction = soapaction
|
2004-12-20 08:50:15 -05:00
|
|
|
@options = options
|
|
|
|
@streamhandler = HTTPStreamHandler.new(
|
|
|
|
@options["protocol.http"] ||= ::SOAP::Property.new)
|
|
|
|
@operation = {}
|
* 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
|
|
|
@mandatorycharset = nil
|
2004-12-20 08:50:15 -05:00
|
|
|
@allow_unqualified_element = true
|
2003-09-24 11:18:44 -04:00
|
|
|
@default_encodingstyle = nil
|
2004-12-20 08:50:15 -05:00
|
|
|
@generate_explicit_type = true
|
|
|
|
@headerhandler = Header::HandlerSet.new
|
|
|
|
@mapping_registry = nil
|
|
|
|
@literal_mapping_registry = ::SOAP::Mapping::WSDLLiteralRegistry.new
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def inspect
|
|
|
|
"#<#{self.class}:#{@endpoint_url}>"
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def endpoint_url
|
|
|
|
@endpoint_url
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def endpoint_url=(endpoint_url)
|
|
|
|
@endpoint_url = endpoint_url
|
|
|
|
reset_stream
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def reset_stream
|
|
|
|
@streamhandler.reset(@endpoint_url)
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def set_wiredump_file_base(wiredump_file_base)
|
|
|
|
@streamhandler.wiredump_file_base = wiredump_file_base
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def test_loopback_response
|
|
|
|
@streamhandler.test_loopback_response
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def add_rpc_method(qname, soapaction, name, param_def, opt = {})
|
|
|
|
opt[:request_style] ||= :rpc
|
|
|
|
opt[:response_style] ||= :rpc
|
|
|
|
opt[:request_use] ||= :encoded
|
|
|
|
opt[:response_use] ||= :encoded
|
|
|
|
@operation[name] = Operation.new(qname, soapaction, 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(qname, soapaction, name, param_def, opt = {})
|
|
|
|
opt[:request_style] ||= :document
|
|
|
|
opt[:response_style] ||= :document
|
|
|
|
opt[:request_use] ||= :literal
|
|
|
|
opt[:response_use] ||= :literal
|
|
|
|
@operation[name] = Operation.new(qname, soapaction, name, param_def, opt)
|
|
|
|
end
|
|
|
|
|
|
|
|
# add_method is for shortcut of typical rpc/encoded method definition.
|
|
|
|
alias add_method add_rpc_method
|
|
|
|
|
|
|
|
def invoke(req_header, req_body, opt = create_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
|
|
|
req_env = SOAPEnvelope.new(req_header, req_body)
|
2004-12-20 08:50:15 -05:00
|
|
|
opt[:external_content] = nil
|
|
|
|
conn_data = marshal(req_env, opt)
|
* 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
|
|
|
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
|
2004-12-20 08:50:15 -05:00
|
|
|
conn_data = @streamhandler.send(@endpoint_url, conn_data, opt[:soapaction])
|
* 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
|
|
|
if conn_data.receive_string.empty?
|
2004-12-20 08:50:15 -05:00
|
|
|
return nil
|
2003-09-24 11:18:44 -04:00
|
|
|
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
|
|
|
unmarshal(conn_data, opt)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def call(name, *params)
|
|
|
|
unless op_info = @operation[name]
|
|
|
|
raise MethodDefinitionError, "Method: #{name} not defined."
|
|
|
|
end
|
|
|
|
req_header = create_request_header
|
|
|
|
req_body = op_info.create_request_body(params, @mapping_registry,
|
|
|
|
@literal_mapping_registry)
|
|
|
|
opt = create_options({
|
|
|
|
:soapaction => op_info.soapaction || @soapaction,
|
|
|
|
:default_encodingstyle => op_info.response_default_encodingstyle})
|
|
|
|
env = invoke(req_header, req_body, opt)
|
|
|
|
receive_headers(env.header)
|
|
|
|
raise EmptyResponseError.new("Empty response.") unless env
|
|
|
|
begin
|
|
|
|
check_fault(env.body)
|
|
|
|
rescue ::SOAP::FaultError => e
|
|
|
|
Mapping.fault2exception(e)
|
|
|
|
end
|
|
|
|
op_info.create_response_obj(env, @mapping_registry,
|
|
|
|
@literal_mapping_registry)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_fault(body)
|
|
|
|
if body.fault
|
|
|
|
raise SOAP::FaultError.new(body.fault)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def create_request_header
|
|
|
|
headers = @headerhandler.on_outbound
|
|
|
|
if headers.empty?
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
h = ::SOAP::SOAPHeader.new
|
|
|
|
headers.each do |header|
|
|
|
|
h.add(header.elename.name, header)
|
|
|
|
end
|
|
|
|
h
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def receive_headers(headers)
|
|
|
|
@headerhandler.on_inbound(headers) if headers
|
|
|
|
end
|
|
|
|
|
|
|
|
def marshal(env, opt)
|
|
|
|
send_string = Processor.marshal(env, opt)
|
|
|
|
StreamHandler::ConnectionData.new(send_string)
|
|
|
|
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)
|
|
|
|
contenttype = conn_data.receive_contenttype
|
|
|
|
if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
|
|
|
|
opt[:external_content] = {}
|
|
|
|
mime = MIMEMessage.parse("Content-Type: " + contenttype,
|
|
|
|
conn_data.receive_string)
|
|
|
|
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] = @mandatorycharset ||
|
|
|
|
StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
|
|
|
|
env = Processor.unmarshal(mime.root.content, opt)
|
|
|
|
else
|
|
|
|
opt[:charset] = @mandatorycharset ||
|
|
|
|
::SOAP::StreamHandler.parse_media_type(contenttype)
|
|
|
|
env = Processor.unmarshal(conn_data.receive_string, opt)
|
|
|
|
end
|
|
|
|
env
|
|
|
|
end
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
def create_header(headers)
|
|
|
|
header = SOAPHeader.new()
|
|
|
|
headers.each do |content, mustunderstand, encodingstyle|
|
|
|
|
header.add(SOAPHeaderItem.new(content, mustunderstand, encodingstyle))
|
|
|
|
end
|
|
|
|
header
|
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def create_options(hash = nil)
|
2003-09-24 11:18:44 -04:00
|
|
|
opt = {}
|
|
|
|
opt[:default_encodingstyle] = @default_encodingstyle
|
2004-12-20 08:50:15 -05:00
|
|
|
opt[:allow_unqualified_element] = @allow_unqualified_element
|
|
|
|
opt[:generate_explicit_type] = @generate_explicit_type
|
|
|
|
opt.update(hash) if hash
|
2003-09-24 11:18:44 -04:00
|
|
|
opt
|
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
|
|
|
|
class Operation
|
|
|
|
attr_reader :soapaction
|
|
|
|
attr_reader :request_style
|
|
|
|
attr_reader :response_style
|
|
|
|
attr_reader :request_use
|
|
|
|
attr_reader :response_use
|
|
|
|
|
|
|
|
def initialize(qname, soapaction, name, param_def, opt)
|
|
|
|
@soapaction = soapaction
|
|
|
|
@request_style = opt[:request_style]
|
|
|
|
@response_style = opt[:response_style]
|
|
|
|
@request_use = opt[:request_use]
|
|
|
|
@response_use = opt[:response_use]
|
|
|
|
@rpc_method_factory = @document_method_name = nil
|
|
|
|
check_style(@request_style)
|
|
|
|
check_style(@response_style)
|
|
|
|
if @request_style == :rpc
|
|
|
|
@rpc_method_factory = SOAPMethodRequest.new(qname, param_def,
|
|
|
|
@soapaction)
|
|
|
|
else
|
|
|
|
@document_method_name = {}
|
|
|
|
param_def.each do |inout, paramname, typeinfo|
|
|
|
|
klass, namespace, name = typeinfo
|
|
|
|
case inout.to_s
|
|
|
|
when "input"
|
|
|
|
@document_method_name[:input] = ::XSD::QName.new(namespace, name)
|
|
|
|
when "output"
|
|
|
|
@document_method_name[:output] = ::XSD::QName.new(namespace, name)
|
|
|
|
else
|
|
|
|
raise MethodDefinitionError, "unknown type: " + inout
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def request_default_encodingstyle
|
|
|
|
(@request_style == :rpc) ? EncodingNamespace : LiteralNamespace
|
|
|
|
end
|
|
|
|
|
|
|
|
def response_default_encodingstyle
|
|
|
|
(@response_style == :rpc) ? EncodingNamespace : LiteralNamespace
|
|
|
|
end
|
|
|
|
|
|
|
|
# for rpc
|
|
|
|
def each_param_name(*target)
|
|
|
|
if @request_style == :rpc
|
|
|
|
@rpc_method_factory.each_param_name(*target) do |name|
|
|
|
|
yield(name)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
yield(@document_method_name[:input].name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_request_body(values, mapping_registry, literal_mapping_registry)
|
|
|
|
if @request_style == :rpc
|
|
|
|
values = Mapping.obj2soap(values, mapping_registry).to_a
|
|
|
|
method = @rpc_method_factory.dup
|
|
|
|
params = {}
|
|
|
|
idx = 0
|
|
|
|
method.each_param_name(::SOAP::RPC::SOAPMethod::IN,
|
|
|
|
::SOAP::RPC::SOAPMethod::INOUT) do |name|
|
|
|
|
params[name] = values[idx] || SOAPNil.new
|
|
|
|
idx += 1
|
|
|
|
end
|
|
|
|
method.set_param(params)
|
|
|
|
SOAPBody.new(method)
|
|
|
|
else
|
|
|
|
name = @document_method_name[:input]
|
|
|
|
document = literal_mapping_registry.obj2soap(values[0], name)
|
|
|
|
SOAPBody.new(document)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_response_obj(env, mapping_registry, literal_mapping_registry)
|
|
|
|
if @response_style == :rpc
|
|
|
|
ret = env.body.response ?
|
|
|
|
Mapping.soap2obj(env.body.response, mapping_registry) : nil
|
|
|
|
if env.body.outparams
|
|
|
|
outparams = env.body.outparams.collect { |outparam|
|
|
|
|
Mapping.soap2obj(outparam)
|
|
|
|
}
|
|
|
|
[ret].concat(outparams)
|
|
|
|
else
|
|
|
|
ret
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Mapping.soap2obj(env.body.root_node, literal_mapping_registry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
ALLOWED_STYLE = [:rpc, :document]
|
|
|
|
def check_style(style)
|
|
|
|
unless ALLOWED_STYLE.include?(style)
|
|
|
|
raise MethodDefinitionError, "unknown style: " + style
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|