From 6a09e1d9664f86b7deb576fb0dfe57e10503bb85 Mon Sep 17 00:00:00 2001 From: nahi Date: Tue, 25 Nov 2003 07:31:33 +0000 Subject: * 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 --- lib/soap/baseData.rb | 23 ++---- lib/soap/element.rb | 23 ++---- lib/soap/encodingstyle/aspDotNetHandler.rb | 23 ++---- lib/soap/encodingstyle/handler.rb | 23 ++---- lib/soap/encodingstyle/literalHandler.rb | 23 ++---- lib/soap/encodingstyle/soapHandler.rb | 111 +++++++++++++++-------------- lib/soap/generator.rb | 23 ++---- lib/soap/mapping.rb | 21 ++---- lib/soap/mapping/factory.rb | 45 ++++++------ lib/soap/mapping/mapping.rb | 23 ++---- lib/soap/mapping/registry.rb | 31 +++----- lib/soap/mapping/rubytypeFactory.rb | 21 ++---- lib/soap/mapping/typeMap.rb | 23 ++---- lib/soap/mapping/wsdlRegistry.rb | 23 ++---- lib/soap/marshal.rb | 30 +++----- lib/soap/netHttpClient.rb | 63 +++++++++------- lib/soap/parser.rb | 23 ++---- lib/soap/processor.rb | 23 ++---- lib/soap/rpc/cgistub.rb | 23 ++---- lib/soap/rpc/driver.rb | 77 ++++++++++---------- lib/soap/rpc/element.rb | 27 +++---- lib/soap/rpc/proxy.rb | 36 ++++------ lib/soap/rpc/router.rb | 23 ++---- lib/soap/rpc/rpc.rb | 23 ++---- lib/soap/rpc/soaplet.rb | 23 ++---- lib/soap/rpc/standaloneServer.rb | 23 ++---- lib/soap/soap.rb | 23 ++---- lib/soap/streamHandler.rb | 28 +++----- lib/soap/wsdlDriver.rb | 87 +++++++++++----------- 29 files changed, 364 insertions(+), 604 deletions(-) (limited to 'lib/soap') diff --git a/lib/soap/baseData.rb b/lib/soap/baseData.rb index c175072e4d..91f5a0433f 100644 --- a/lib/soap/baseData.rb +++ b/lib/soap/baseData.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Base type library -Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi. +# soap/baseData.rb: SOAP4R - Base type library +# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'xsd/datatypes' @@ -408,7 +397,7 @@ public private def add_member(name, value = nil) - value = SOAPNil.new() unless value + value = SOAPNil.new() if value.nil? @array.push(name) value.elename = value.elename.dup_name(name) @data.push(value) diff --git a/lib/soap/element.rb b/lib/soap/element.rb index 561cb1b071..ae600a08e2 100644 --- a/lib/soap/element.rb +++ b/lib/soap/element.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - SOAP elements library -Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - SOAP elements library +# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'xsd/qname' diff --git a/lib/soap/encodingstyle/aspDotNetHandler.rb b/lib/soap/encodingstyle/aspDotNetHandler.rb index b00084e3a9..e976433a7b 100644 --- a/lib/soap/encodingstyle/aspDotNetHandler.rb +++ b/lib/soap/encodingstyle/aspDotNetHandler.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - ASP.NET EncodingStyle handler library -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - ASP.NET EncodingStyle handler library +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'soap/encodingstyle/handler' diff --git a/lib/soap/encodingstyle/handler.rb b/lib/soap/encodingstyle/handler.rb index 2cbbd893d8..8ea23ef146 100644 --- a/lib/soap/encodingstyle/handler.rb +++ b/lib/soap/encodingstyle/handler.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - EncodingStyle handler library -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - EncodingStyle handler library +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'soap/soap' diff --git a/lib/soap/encodingstyle/literalHandler.rb b/lib/soap/encodingstyle/literalHandler.rb index 5ff0e5dd66..995e1a5361 100644 --- a/lib/soap/encodingstyle/literalHandler.rb +++ b/lib/soap/encodingstyle/literalHandler.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - XML Literal EncodingStyle handler library -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - XML Literal EncodingStyle handler library +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'soap/encodingstyle/handler' diff --git a/lib/soap/encodingstyle/soapHandler.rb b/lib/soap/encodingstyle/soapHandler.rb index 0c68810cce..51780f5520 100644 --- a/lib/soap/encodingstyle/soapHandler.rb +++ b/lib/soap/encodingstyle/soapHandler.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - SOAP EncodingStyle handler library -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. +# SOAP4R - SOAP EncodingStyle handler library +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'soap/encodingstyle/handler' @@ -172,10 +161,9 @@ class SOAPHandler < Handler elsif href o = SOAPReference.decode(elename, href) @refpool << o - elsif @decode_typemap && - (parent.node.class != SOAPBody || @is_first_top_ele) - # multi-ref element should be parsed by decode_tag_by_type. - @is_first_top_ele = false + elsif @decode_typemap + # to parse multi-ref element with decode_tag_by_type. + # && (parent.node.class != SOAPBody || @is_first_top_ele) o = decode_tag_by_wsdl(ns, elename, type, parent.node, arytype, extraattr) else o = decode_tag_by_type(ns, elename, type, parent.node, arytype, extraattr) @@ -344,15 +332,30 @@ private end def decode_tag_by_wsdl(ns, elename, typestr, parent, arytypestr, extraattr) + o = nil if parent.class == SOAPBody - # Unqualified name is allowed here. - type = @decode_typemap[elename] || @decode_typemap.find_name(elename.name) - unless type - raise EncodingStyleError.new("Unknown operation '#{ elename }'.") + if @is_first_top_ele + # Unqualified name is allowed here. + @is_first_top_ele = false + type = @decode_typemap[elename] || + @decode_typemap.find_name(elename.name) + unless type + raise EncodingStyleError.new("Unknown operation '#{ elename }'.") + end + o = SOAPStruct.new(elename) + o.definedtype = type + return o + elsif !typestr + # typeless multi-ref element. + return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, + extraattr) + else + # typed multi-ref element. + typename = ns.parse(typestr) + typedef = @decode_typemap[typename] + return decode_defined_compoundtype(elename, typename, typedef, + arytypestr) end - o = SOAPStruct.new(elename) - o.definedtype = type - return o end if parent.type == XSD::AnyTypeName @@ -366,41 +369,41 @@ private unless parenttype raise EncodingStyleError.new("Unknown type '#{ parent.type }'.") end - typename = parenttype.child_type(elename) - if typename - if (klass = TypeMap[typename]) - return klass.decode(elename) - elsif typename == XSD::AnyTypeName - return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, - extraattr) - end + + definedtype_name = parenttype.child_type(elename) + if definedtype_name and (klass = TypeMap[definedtype_name]) + return klass.decode(elename) + elsif definedtype_name == XSD::AnyTypeName + return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, + extraattr) end - type = if typename - @decode_typemap[typename] - else - parenttype.child_defined_complextype(elename) - end - unless type + typedef = definedtype_name ? @decode_typemap[definedtype_name] : + parenttype.child_defined_complextype(elename) + decode_defined_compoundtype(elename, definedtype_name, typedef, arytypestr) + end + + def decode_defined_compoundtype(elename, typename, typedef, arytypestr) + unless typedef raise EncodingStyleError.new("Unknown type '#{ typename }'.") end - - case type.compoundtype + case typedef.compoundtype when :TYPE_STRUCT o = SOAPStruct.decode(elename, typename) - o.definedtype = type + o.definedtype = typedef return o when :TYPE_ARRAY - expected_arytype = type.find_arytype - actual_arytype = if arytypestr - XSD::QName.new(expected_arytype.namespace, - content_typename(expected_arytype.name) << - content_ranksize(arytypestr)) - else - expected_arytype - end - o = SOAPArray.decode(elename, typename, actual_arytype) - o.definedtype = type + expected_arytype = typedef.find_arytype + if arytypestr + actual_arytype = XSD::QName.new(expected_arytype.namespace, + content_typename(expected_arytype.name) << + content_ranksize(arytypestr)) + o = SOAPArray.decode(elename, typename, actual_arytype) + else + o = SOAPArray.new(typename, 1, expected_arytype) + o.elename = elename + end + o.definedtype = typedef return o end return nil diff --git a/lib/soap/generator.rb b/lib/soap/generator.rb index 7ddb105f7d..dd868fb9db 100644 --- a/lib/soap/generator.rb +++ b/lib/soap/generator.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - SOAP XML Instance Generator library. -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - SOAP XML Instance Generator library. +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'xsd/ns' diff --git a/lib/soap/mapping.rb b/lib/soap/mapping.rb index 8da1978a4f..b83f8b484a 100644 --- a/lib/soap/mapping.rb +++ b/lib/soap/mapping.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Ruby type mapping utility. -Copyright (C) 2003 NAKAMURA, Hiroshi. +# SOAP4R - Ruby type mapping utility. +# Copyright (C) 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'soap/mapping/mapping' diff --git a/lib/soap/mapping/factory.rb b/lib/soap/mapping/factory.rb index 631c161134..509fe369c4 100644 --- a/lib/soap/mapping/factory.rb +++ b/lib/soap/mapping/factory.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Mapping factory. -Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi. +# SOAP4R - Mapping factory. +# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. module SOAP @@ -73,11 +62,11 @@ class Factory def setiv2obj(obj, node, map) return if node.nil? - vars = {} - node.each do |name, value| - vars[Mapping.elename2name(name)] = Mapping._soap2obj(value, map) + if obj.is_a?(Array) + setiv2ary(obj, node, map) + else + setiv2struct(obj, node, map) end - Mapping.set_instance_vars(obj, vars) end def setiv2soap(node, obj, map) @@ -105,6 +94,22 @@ class Factory def capitalize(target) target.gsub(/^([a-z])/) { $1.tr!('[a-z]', '[A-Z]') } end + +private + + def setiv2ary(obj, node, map) + node.each do |name, value| + Array.instance_method(:<<).bind(obj).call(Mapping._soap2obj(value, map)) + end + end + + def setiv2struct(obj, node, map) + vars = {} + node.each do |name, value| + vars[Mapping.elename2name(name)] = Mapping._soap2obj(value, map) + end + Mapping.set_instance_vars(obj, vars) + end end class StringFactory_ < Factory diff --git a/lib/soap/mapping/mapping.rb b/lib/soap/mapping/mapping.rb index f660c2c63f..32be9839c8 100644 --- a/lib/soap/mapping/mapping.rb +++ b/lib/soap/mapping/mapping.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Ruby type mapping utility. -Copyright (C) 2000, 2001, 2003 NAKAMURA Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - Ruby type mapping utility. +# Copyright (C) 2000, 2001, 2003 NAKAMURA Hiroshi . + +# 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. module SOAP diff --git a/lib/soap/mapping/registry.rb b/lib/soap/mapping/registry.rb index e98c98a6d4..51ad939d99 100644 --- a/lib/soap/mapping/registry.rb +++ b/lib/soap/mapping/registry.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Mapping registry. -Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi. +# SOAP4R - Mapping registry. +# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'soap/baseData' @@ -145,7 +134,7 @@ class Registry @registry = registry end - def obj2soap(klass, obj) + def obj2soap(klass, obj, type_qname = nil) @map.each do |obj_class, soap_class, factory, info| if klass == obj_class or (info[:derived_class] and klass <= obj_class) @@ -330,8 +319,8 @@ class Registry alias :set :add # This mapping registry ignores type hint. - def obj2soap(klass, obj, type = nil) - soap = _obj2soap(klass, obj, type) + def obj2soap(klass, obj, type_qname = nil) + soap = _obj2soap(klass, obj, type_qname) if @allow_original_mapping addextend2soap(soap, obj) end @@ -369,7 +358,7 @@ class Registry private - def _obj2soap(klass, obj, type) + def _obj2soap(klass, obj, type_qname) ret = nil if obj.is_a?(SOAPStruct) or obj.is_a?(SOAPArray) obj.replace do |ele| @@ -380,7 +369,7 @@ private return obj end begin - ret = @map.obj2soap(klass, obj) || + ret = @map.obj2soap(klass, obj, type_qname) || @default_factory.obj2soap(klass, obj, nil, self) rescue MappingError end diff --git a/lib/soap/mapping/rubytypeFactory.rb b/lib/soap/mapping/rubytypeFactory.rb index 3ebb799220..0b4af8b8e4 100644 --- a/lib/soap/mapping/rubytypeFactory.rb +++ b/lib/soap/mapping/rubytypeFactory.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Ruby type mapping factory. -Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi. +# SOAP4R - Ruby type mapping factory. +# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. module SOAP diff --git a/lib/soap/mapping/typeMap.rb b/lib/soap/mapping/typeMap.rb index c62f1482c1..93f24b4bd8 100644 --- a/lib/soap/mapping/typeMap.rb +++ b/lib/soap/mapping/typeMap.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Base type mapping definition -Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - Base type mapping definition +# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi . + +# 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. module SOAP diff --git a/lib/soap/mapping/wsdlRegistry.rb b/lib/soap/mapping/wsdlRegistry.rb index 4b5beabe72..66d16c6f90 100644 --- a/lib/soap/mapping/wsdlRegistry.rb +++ b/lib/soap/mapping/wsdlRegistry.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - WSDL mapping registry. -Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - WSDL mapping registry. +# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi . + +# 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. require 'soap/baseData' diff --git a/lib/soap/marshal.rb b/lib/soap/marshal.rb index 5c25fad0de..910ab24527 100644 --- a/lib/soap/marshal.rb +++ b/lib/soap/marshal.rb @@ -1,25 +1,9 @@ -=begin -SOAP4R - Marshalling/Unmarshalling Ruby's object using SOAP Encoding. -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. +# SOAP4R - Marshalling/Unmarshalling Ruby's object using SOAP Encoding. +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end - - -# The original version of the marshal.rb to marshal/unmarshal Ruby's object -# using SOAP Encoding was written by Michael Neumann. His valuable comments -# and his program inspired me to write this. Thanks. +# 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. require "soap/mapping" @@ -58,7 +42,9 @@ module Marshal def unmarshal(stream, mapping_registry = MarshalMappingRegistry) header, body = SOAP::Processor.unmarshal(stream) - #Mapping.soap2obj(body.root_node, mapping_registry) + if body.nil? + raise ArgumentError.new("Illegal SOAP marshal format.") + end Mapping.soap2obj(body.root_node, mapping_registry) end end diff --git a/lib/soap/netHttpClient.rb b/lib/soap/netHttpClient.rb index facdcb7279..04d1937133 100644 --- a/lib/soap/netHttpClient.rb +++ b/lib/soap/netHttpClient.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - net/http wrapper -Copyright (C) 2003 NAKAMURA, Hiroshi. +# SOAP4R - net/http wrapper +# Copyright (C) 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'net/http' @@ -25,6 +14,13 @@ module SOAP class NetHttpClient + SSLEnabled = begin + require 'net/https' + true + rescue LoadError + false + end + attr_accessor :proxy attr_accessor :no_proxy attr_accessor :debug_dev @@ -86,20 +82,39 @@ class NetHttpClient private def start(url) + http = create_connection(url) + response = nil + http.start { |worker| + response, = yield(worker) + worker.finish + } + @debug_dev << response.body if @debug_dev + response + end + + def create_connection(url) proxy_host = proxy_port = nil unless no_proxy?(url) proxy_host = @proxy.host proxy_port = @proxy.port end - response = nil - Net::HTTP::Proxy(proxy_host, proxy_port).start(url.host, url.port) { |http| - if http.respond_to?(:set_debug_output) - http.set_debug_output(@debug_dev) + http = Net::HTTP::Proxy(proxy_host, proxy_port).new(url.host, url.port) + if http.respond_to?(:set_debug_output) + http.set_debug_output(@debug_dev) + end + case url + when URI::HTTPS + if SSLEnabled + http.use_ssl = true + else + raise RuntimeError.new("Cannot connect to #{url} (OpenSSL is not installed.)") end - response, = yield(http) - http.finish - } - response + when URI::HTTP + # OK + else + raise RuntimeError.new("Cannot connect to #{url} (Not HTTP.)") + end + http end NO_PROXY_HOSTS = ['localhost'] diff --git a/lib/soap/parser.rb b/lib/soap/parser.rb index 67782566c3..1395be55ec 100644 --- a/lib/soap/parser.rb +++ b/lib/soap/parser.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - SOAP XML Instance Parser library. -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - SOAP XML Instance Parser library. +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'xsd/ns' diff --git a/lib/soap/processor.rb b/lib/soap/processor.rb index 47df772a9d..9cf00e8340 100644 --- a/lib/soap/processor.rb +++ b/lib/soap/processor.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - marshal/unmarshal interface. -Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - marshal/unmarshal interface. +# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'xsd/datatypes' diff --git a/lib/soap/rpc/cgistub.rb b/lib/soap/rpc/cgistub.rb index e89314d132..2377f343b5 100644 --- a/lib/soap/rpc/cgistub.rb +++ b/lib/soap/rpc/cgistub.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - CGI stub library -Copyright (C) 2001, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - CGI stub library +# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi . + +# 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. require 'soap/streamHandler' diff --git a/lib/soap/rpc/driver.rb b/lib/soap/rpc/driver.rb index 76fd14e34b..739c8774d4 100644 --- a/lib/soap/rpc/driver.rb +++ b/lib/soap/rpc/driver.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - SOAP RPC driver -Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi. +# SOAP4R - SOAP RPC driver +# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'soap/soap' @@ -35,51 +24,63 @@ public attr_accessor :mapping_registry attr_accessor :soapaction - attr_reader :endpoint_url attr_reader :wiredump_dev attr_reader :wiredump_file_base - attr_reader :httpproxy + attr_reader :streamhandler def initialize(endpoint_url, namespace, soapaction = nil) - @endpoint_url = endpoint_url @namespace = namespace @mapping_registry = nil # for unmarshal @soapaction = soapaction @wiredump_dev = nil @wiredump_file_base = nil - @httpproxy = ENV['httpproxy'] || ENV['HTTP_PROXY'] - @handler = HTTPPostStreamHandler.new(@endpoint_url, @httpproxy, + name = 'http_proxy' + @httpproxy = ENV[name] || ENV[name.upcase] + @streamhandler = HTTPPostStreamHandler.new(endpoint_url, @httpproxy, XSD::Charset.encoding_label) - @proxy = Proxy.new(@handler, @soapaction) + @proxy = Proxy.new(@streamhandler, @soapaction) @proxy.allow_unqualified_element = true end + def inspect + "#<#{self.class}:#{@streamhandler.inspect}>" + end + + def endpoint_url + @streamhandler.endpoint_url + end + def endpoint_url=(endpoint_url) - @endpoint_url = endpoint_url - if @handler - @handler.endpoint_url = @endpoint_url - @handler.reset - end + @streamhandler.endpoint_url = endpoint_url + @streamhandler.reset end def wiredump_dev=(dev) @wiredump_dev = dev - if @handler - @handler.wiredump_dev = @wiredump_dev - @handler.reset - end + @streamhandler.wiredump_dev = @wiredump_dev + @streamhandler.reset end def wiredump_file_base=(base) @wiredump_file_base = base end + def httpproxy + @httpproxy + end + def httpproxy=(httpproxy) @httpproxy = httpproxy - if @handler - @handler.proxy = @httpproxy - @handler.reset - end + @streamhandler.proxy = @httpproxy + @streamhandler.reset + end + + def mandatorycharset + @proxy.mandatorycharset + end + + def mandatorycharset=(mandatorycharset) + @proxy.mandatorycharset = mandatorycharset end def default_encodingstyle @@ -126,7 +127,7 @@ public # def invoke(headers, body) if @wiredump_file_base - @handler.wiredump_file_base = + @streamhandler.wiredump_file_base = @wiredump_file_base + '_' << body.elename.name end @proxy.invoke(headers, body) @@ -136,7 +137,7 @@ public # Convert parameters: params array => SOAPArray => members array params = Mapping.obj2soap(params, @mapping_registry).to_a if @wiredump_file_base - @handler.wiredump_file_base = @wiredump_file_base + '_' << name + @streamhandler.wiredump_file_base = @wiredump_file_base + '_' << name end # Then, call @proxy.call like the following. @@ -161,7 +162,7 @@ public end def reset_stream - @handler.reset + @streamhandler.reset end private diff --git a/lib/soap/rpc/element.rb b/lib/soap/rpc/element.rb index d1e1931fa3..395823ab00 100644 --- a/lib/soap/rpc/element.rb +++ b/lib/soap/rpc/element.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - RPC element definition. -Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi. +# SOAP4R - RPC element definition. +# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'soap/baseData' @@ -180,10 +169,10 @@ class SOAPMethodRequest < SOAPMethod params.each do |param| param_name = "p#{ i }" i += 1 - param_def << [IN, nil, param_name] + param_def << [IN, param_name, nil] param_value << [param_name, param] end - param_def << [RETVAL, nil, 'return'] + param_def << [RETVAL, 'return', nil] o = new(qname, param_def) o.set_param(param_value) o @@ -236,7 +225,7 @@ class SOAPMethodResponse < SOAPMethod def retval=(retval) @retval = retval - @retval.elename = @retval.elename.dup_name('return') + @retval.elename = @retval.elename.dup_name(@retval_name || 'return') end def each diff --git a/lib/soap/rpc/proxy.rb b/lib/soap/rpc/proxy.rb index 39a095838c..5825a27138 100644 --- a/lib/soap/rpc/proxy.rb +++ b/lib/soap/rpc/proxy.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - RPC Proxy library. -Copyright (C) 2000, 2003 NAKAMURA, Hiroshi. +# SOAP4R - RPC Proxy library. +# Copyright (C) 2000, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'soap/soap' @@ -35,13 +24,16 @@ class Proxy public attr_accessor :soapaction - attr_accessor :allow_unqualified_element, :default_encodingstyle + attr_accessor :mandatorycharset + attr_accessor :allow_unqualified_element + attr_accessor :default_encodingstyle attr_reader :method - def initialize(stream_handler, soapaction = nil) - @handler = stream_handler + def initialize(streamhandler, soapaction = nil) + @streamhandler = streamhandler @soapaction = soapaction @method = {} + @mandatorycharset = nil @allow_unqualified_element = false @default_encodingstyle = nil end @@ -100,13 +92,13 @@ public end opt = create_options send_string = Processor.marshal(req_header, req_body, opt) - data = @handler.send(send_string, soapaction) + data = @streamhandler.send(send_string, soapaction) if data.receive_string.empty? return nil, nil end - res_charset = StreamHandler.parse_media_type(data.receive_contenttype) opt = create_options - opt[:charset] = res_charset + opt[:charset] = @mandatorycharset || + StreamHandler.parse_media_type(data.receive_contenttype) res_header, res_body = Processor.unmarshal(data.receive_string, opt) return res_header, res_body end diff --git a/lib/soap/rpc/router.rb b/lib/soap/rpc/router.rb index 20396a4a7d..527ec05768 100644 --- a/lib/soap/rpc/router.rb +++ b/lib/soap/rpc/router.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - RPC Routing library -Copyright (C) 2001, 2002 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - RPC Routing library +# Copyright (C) 2001, 2002 NAKAMURA, Hiroshi . + +# 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. require 'soap/soap' diff --git a/lib/soap/rpc/rpc.rb b/lib/soap/rpc/rpc.rb index c3cb3228f5..5f77b4d2e9 100644 --- a/lib/soap/rpc/rpc.rb +++ b/lib/soap/rpc/rpc.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - RPC utility. -Copyright (C) 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - RPC utility. +# Copyright (C) 2003 NAKAMURA, Hiroshi . + +# 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. module SOAP diff --git a/lib/soap/rpc/soaplet.rb b/lib/soap/rpc/soaplet.rb index 1a4ef99b76..4b25c68161 100644 --- a/lib/soap/rpc/soaplet.rb +++ b/lib/soap/rpc/soaplet.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - SOAP handler servlet for WEBrick -Copyright (C) 2001, 2002, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - SOAP handler servlet for WEBrick +# Copyright (C) 2001, 2002, 2003 NAKAMURA, Hiroshi . + +# 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. require 'webrick/httpservlet/abstract' diff --git a/lib/soap/rpc/standaloneServer.rb b/lib/soap/rpc/standaloneServer.rb index 8862f7606e..f3f225c7dc 100644 --- a/lib/soap/rpc/standaloneServer.rb +++ b/lib/soap/rpc/standaloneServer.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - WEBrick Server -Copyright (C) 2003 by NAKAMURA, Hiroshi - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# SOAP4R - WEBrick Server +# Copyright (C) 2003 by NAKAMURA, Hiroshi . + +# 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. require 'logger' diff --git a/lib/soap/soap.rb b/lib/soap/soap.rb index 2543ec3612..fcfbb2ef2b 100644 --- a/lib/soap/soap.rb +++ b/lib/soap/soap.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Base definitions. -Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# soap/soap.rb: SOAP4R - Base definitions. +# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi . + +# 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. require 'xsd/qname' diff --git a/lib/soap/streamHandler.rb b/lib/soap/streamHandler.rb index a9068b368d..7dcb2d62d6 100644 --- a/lib/soap/streamHandler.rb +++ b/lib/soap/streamHandler.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - Stream handler. -Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi. +# SOAP4R - Stream handler. +# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'soap/soap' @@ -73,7 +62,7 @@ class StreamHandler end charset = $1 charset.gsub!(/"/, '') if charset - charset + charset || 'us-ascii' end def self.create_media_type(charset) @@ -90,6 +79,7 @@ public attr_accessor :wiredump_dev attr_accessor :wiredump_file_base attr_accessor :charset + attr_reader :client NofRetry = 10 # [times] ConnectTimeout = 20 # [sec] @@ -108,6 +98,10 @@ public @client.session_manager.receive_timeout = ReceiveTimeout end + def inspect + "#<#{self.class}:#{endpoint_url}>" + end + def proxy=(proxy) @proxy = proxy @client.proxy = @proxy diff --git a/lib/soap/wsdlDriver.rb b/lib/soap/wsdlDriver.rb index 6ecc4b4f6e..d629aa12ce 100644 --- a/lib/soap/wsdlDriver.rb +++ b/lib/soap/wsdlDriver.rb @@ -1,20 +1,9 @@ -=begin -SOAP4R - SOAP WSDL driver -Copyright (C) 2002, 2003 NAKAMURA, Hiroshi. +# SOAP4R - SOAP WSDL driver +# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi . -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PRATICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 675 Mass -Ave, Cambridge, MA 02139, USA. -=end +# 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. require 'wsdl/parser' @@ -43,6 +32,10 @@ class WSDLDriverFactory @logdev = logdev @wsdl = import(wsdl) end + + def inspect + "#<#{self.class}:#{@wsdl.name}>" + end def create_driver(servicename = nil, portname = nil, opt = {}) service = if servicename @@ -105,6 +98,7 @@ class WSDLDriver __attr_proxy :wiredump_dev, true __attr_proxy :wiredump_file_base, true __attr_proxy :httpproxy, true + __attr_proxy :mandatorycharset, true # force using charset __attr_proxy :default_encodingstyle, true __attr_proxy :allow_unqualified_element, true @@ -121,14 +115,16 @@ class WSDLDriver include Logger::Severity include SOAP + attr_reader :wsdl + attr_reader :port attr_reader :opt attr_accessor :logdev attr_accessor :mapping_registry attr_accessor :wsdl_mapping_registry - attr_reader :endpoint_url attr_reader :wiredump_dev attr_reader :wiredump_file_base attr_reader :httpproxy + attr_accessor :mandatorycharset attr_accessor :default_encodingstyle attr_accessor :allow_unqualified_element @@ -220,11 +216,9 @@ class WSDLDriver @opt = opt.dup @mapping_registry = nil # for rpc unmarshal @wsdl_mapping_registry = nil # for rpc marshal - @endpoint_url = nil @wiredump_dev = nil @wiredump_file_base = nil - name = 'http_proxy' - @httpproxy = ENV[name] || ENV[name.upcase] + @mandatorycharset = nil @wsdl_elements = @wsdl.collect_elements @wsdl_types = @wsdl.collect_complextypes @@ -235,7 +229,8 @@ class WSDLDriver @allow_unqualified_element = true @generate_explicit_type = false - create_handler + create_streamhandler(@port.soap_address.location, + ENV['http_proxy'] || ENV['HTTP_PROXY']) @operations = {} # Convert a map which key is QName, to a Hash which key is String. @port.inputoperation_map.each do |op_name, op_info| @@ -244,21 +239,20 @@ class WSDLDriver end end + def endpoint_url + @streamhandler.endpoint_url + end + def endpoint_url=(endpoint_url) - @endpoint_url = endpoint_url - if @handler - @handler.endpoint_url = @endpoint_url - @handler.reset - end - log(DEBUG) { "endpoint_url=: set endpoint_url #{ @endpoint_url }." } + @streamhandler.endpoint_url = endpoint_url + @streamhandler.reset + log(DEBUG) { "endpoint_url=: set endpoint_url #{ endpoint_url }." } end def wiredump_dev=(dev) @wiredump_dev = dev - if @handler - @handler.wiredump_dev = @wiredump_dev - @handler.reset - end + @streamhandler.wiredump_dev = @wiredump_dev + @streamhandler.reset end def wiredump_file_base=(base) @@ -266,16 +260,13 @@ class WSDLDriver end def httpproxy=(httpproxy) - @httpproxy = httpproxy - if @handler - @handler.proxy = @httpproxy - @handler.reset - end - log(DEBUG) { "httpproxy=: set httpproxy #{ @httpproxy }." } + @streamhandler.proxy = httpproxy + @streamhandler.reset + log(DEBUG) { "httpproxy=: set httpproxy #{ httpproxy }." } end def reset_stream - @handler.reset + @streamhandler.reset end def rpc_send(method_name, *params) @@ -292,7 +283,8 @@ class WSDLDriver req_body = SOAPBody.new(method) if @wiredump_file_base - @handler.wiredump_file_base = @wiredump_file_base + '_' << method_name + @streamhandler.wiredump_file_base = + @wiredump_file_base + '_' << method_name end begin @@ -338,11 +330,10 @@ class WSDLDriver private - def create_handler - endpoint_url = @endpoint_url || @port.soap_address.location - @handler = HTTPPostStreamHandler.new(endpoint_url, @httpproxy, + def create_streamhandler(endpoint_url, httpproxy) + @streamhandler = HTTPPostStreamHandler.new(endpoint_url, httpproxy, XSD::Charset.encoding_label) - @handler.wiredump_dev = @wiredump_dev + @streamhandler.wiredump_dev = @wiredump_dev end def create_method_obj(names, params) @@ -356,13 +347,13 @@ class WSDLDriver def invoke(req_header, req_body, op_info, opt) send_string = Processor.marshal(req_header, req_body, opt) log(DEBUG) { "invoke: sending string #{ send_string }" } - data = @handler.send(send_string, op_info.soapaction) + data = @streamhandler.send(send_string, op_info.soapaction) log(DEBUG) { "invoke: received string #{ data.receive_string }" } if data.receive_string.empty? return nil, nil end - res_charset = StreamHandler.parse_media_type(data.receive_contenttype) - opt[:charset] = res_charset + opt[:charset] = @mandatorycharset || + StreamHandler.parse_media_type(data.receive_contenttype) res_header, res_body = Processor.unmarshal(data.receive_string, opt) return res_header, res_body end @@ -483,6 +474,10 @@ class WSDLDriver def initialize(wsdl, port, logdev, opt) @servant = Servant__.new(self, wsdl, port, logdev, opt) end + + def inspect + "#<#{self.class}:#{@servant.port.name}>" + end end -- cgit v1.2.3