diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-15 14:33:53 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-15 14:33:53 +0000 |
commit | 29c5ab0b77feaf975d83ab340d7194c9c4dffc9d (patch) | |
tree | 6ac40e3bffcf1735c8b7efc0f412bccc15befa6a /lib/wsdl/soap | |
parent | 071c45df939e962e8cd6ecc51bd402b6a7cc91f6 (diff) | |
download | ruby-29c5ab0b77feaf975d83ab340d7194c9c4dffc9d.tar.gz |
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.5.
#nnn is a ticket number at http://dev.ctor.org/soap4r
* SOAP
* allow to configure an envelope namespace of SOAP request. (#124)
TemporaryNamespace = 'http://www.w3.org/2003/05/soap-envelope'
@client.options["soap.envelope.requestnamespace"] =
TemporaryNamespace
@client.options["soap.envelope.responsenamespace"] =
TemporaryNamespace
@client.do_proc(...)
* let SOAP request XML indent space configuable. see
"soap.envelope.no_indent" option. (#130)
* let external CES configuable.
ex. client["soap.mapping.external_ces"] = 'SJIS'. $KCODE is used
by default. (#133)
external CES ::= CES used in Ruby object of client and server
internal CES ::= CES used in SOAP/OM
* add iso-8859-1 external CES support. (#106)
* fixed illegal 'qualified' handling of elements. it caused
ASP.NET inteoperability problem. (#144)
* added 'soap.envelope.use_numeric_character_reference' (boolean)
option to let query XML use numeric character reference in XML,
not plain UTF-8 character. !GoogleSearch server seems to not
allow plain UTF-8 character since 2005-08-15 update. (#147)
* SOAP::Header::SimpleHeader (de)serialization throws an exception
on !SimpleHeader.on_(in|out)bound when header is a String. so we
could not use a simple single element headerItem. fixed. thanks
to emil. (#129)
* out parameter of rpc operation did not work. (#132)
* follow HTTP redirect only if using http-access2. (#125) (#145)
* add a workaround for importing an WSDL whose path begins with
drive letter. (#115)
* WSDL
* SOAP Data which is defined as a simpletype was not mapped
correctly to Ruby obj when using wsdl2ruby.rb generated classdef
file. (#123)
* rpc/literal support. (#118)
* re-implemented local element qualify/unqualify control. handles
elementFormDefault and form in WSDL. (#119)
* Array of an element which has simpleType causes a crash. (#128)
* prarmeterOrder may not contain return part so it can be shorter
than parts size. Thanks to Hugh. (#139)
* Samples
* added !BasicAuth client sample. (#117)
* added Base64 client/server sample.
* added Flickr SOAP interface client sample. (#122)
* added !SalesForce client sample. (#135)
* updated Thawte CA certificate for !GoogleAdWords sample.
* updated a client script with the newer version made by Johan.
thanks!
* shortened long file names. (#120)
* fixed typo in authheader sample. (#129)
* updated deprecated method usage. (#138)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/wsdl/soap')
-rw-r--r-- | lib/wsdl/soap/body.rb | 6 | ||||
-rw-r--r-- | lib/wsdl/soap/cgiStubCreator.rb | 10 | ||||
-rw-r--r-- | lib/wsdl/soap/classDefCreator.rb | 54 | ||||
-rw-r--r-- | lib/wsdl/soap/clientSkeltonCreator.rb | 4 | ||||
-rw-r--r-- | lib/wsdl/soap/complexType.rb | 31 | ||||
-rw-r--r-- | lib/wsdl/soap/driverCreator.rb | 22 | ||||
-rw-r--r-- | lib/wsdl/soap/methodDefCreator.rb | 77 | ||||
-rw-r--r-- | lib/wsdl/soap/standaloneServerStubCreator.rb | 10 |
8 files changed, 164 insertions, 50 deletions
diff --git a/lib/wsdl/soap/body.rb b/lib/wsdl/soap/body.rb index 47e99f381b..824f8121a2 100644 --- a/lib/wsdl/soap/body.rb +++ b/lib/wsdl/soap/body.rb @@ -36,7 +36,11 @@ class Body < Info when PartsAttrName @parts = value.source when UseAttrName - @use = value.source + if ['literal', 'encoded'].include?(value.source) + @use = value.source.intern + else + raise RuntimeError.new("unknown use of soap:body: #{value.source}") + end when EncodingStyleAttrName @encodingstyle = value.source when NamespaceAttrName diff --git a/lib/wsdl/soap/cgiStubCreator.rb b/lib/wsdl/soap/cgiStubCreator.rb index 0a76dc43a1..2c4dff2f62 100644 --- a/lib/wsdl/soap/cgiStubCreator.rb +++ b/lib/wsdl/soap/cgiStubCreator.rb @@ -53,12 +53,12 @@ Methods = [ <<-EOD super(*arg) servant = #{class_name}.new - #{class_name}::Methods.each do |name_as, name, param_def, soapaction, namespace, style| - if style == :document - @router.add_document_operation(servant, soapaction, name, param_def) + #{class_name}::Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + @router.add_document_operation(servant, *definitions) else - qname = XSD::QName.new(namespace, name_as) - @router.add_rpc_operation(servant, qname, soapaction, name, param_def) + @router.add_rpc_operation(servant, *definitions) end end self.mapping_registry = #{class_name}::MappingRegistry diff --git a/lib/wsdl/soap/classDefCreator.rb b/lib/wsdl/soap/classDefCreator.rb index deda4f131f..aeb67c0613 100644 --- a/lib/wsdl/soap/classDefCreator.rb +++ b/lib/wsdl/soap/classDefCreator.rb @@ -57,7 +57,8 @@ private def dump_element @elements.collect { |ele| if ele.local_complextype - dump_classdef(ele.name, ele.local_complextype) + dump_classdef(ele.name, ele.local_complextype, + ele.elementform == 'qualified') elsif ele.local_simpletype dump_simpletypedef(ele.name, ele.local_simpletype) else @@ -117,7 +118,7 @@ private c.dump end - def dump_classdef(qname, typedef) + def dump_classdef(qname, typedef, qualified = false) if @faulttypes and @faulttypes.index(qname) c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::StandardError') @@ -127,6 +128,7 @@ private c.comment = "#{qname}" c.def_classvar('schema_type', ndq(qname.name)) c.def_classvar('schema_ns', ndq(qname.namespace)) + c.def_classvar('schema_qualified', dq('true')) if qualified schema_element = [] init_lines = '' params = [] @@ -158,7 +160,10 @@ private else params << "#{varname} = nil" end - eleqname = (varname == name) ? nil : element.name + # nil means @@schema_ns + varname + eleqname = + (varname == name && element.name.namespace == qname.namespace) ? + nil : element.name schema_element << [varname, eleqname, type] end unless typedef.attributes.empty? @@ -256,13 +261,50 @@ private raise RuntimeError.new("cannot define name of #{attribute}") end + DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item') + def dump_arraydef(complextype) qname = complextype.name c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::Array') c.comment = "#{qname}" - type = complextype.child_type - c.def_classvar('schema_type', ndq(type.name)) - c.def_classvar('schema_ns', ndq(type.namespace)) + child_type = complextype.child_type + c.def_classvar('schema_type', ndq(child_type.name)) + c.def_classvar('schema_ns', ndq(child_type.namespace)) + child_element = complextype.find_aryelement + schema_element = [] + if child_type == XSD::AnyTypeName + type = nil + elsif child_element and (klass = element_basetype(child_element)) + type = klass.name + elsif child_type + type = create_class_name(child_type) + else + type = nil + end + if child_element + if child_element.map_as_array? + type << '[]' if type + end + child_element_name = child_element.name + else + child_element_name = DEFAULT_ITEM_NAME + end + schema_element << [child_element_name.name, child_element_name, type] + c.def_classvar('schema_element', + '[' + + schema_element.collect { |varname, name, type| + '[' + + ( + if name + varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']' + else + varname.dump + ', ' + ndq(type) + end + ) + + ']' + }.join(', ') + + ']' + ) c.dump end end diff --git a/lib/wsdl/soap/clientSkeltonCreator.rb b/lib/wsdl/soap/clientSkeltonCreator.rb index 0b9e79c718..916f0d4dc0 100644 --- a/lib/wsdl/soap/clientSkeltonCreator.rb +++ b/lib/wsdl/soap/clientSkeltonCreator.rb @@ -42,8 +42,8 @@ private endpoint_url = ARGV.shift obj = #{ drv_name }.new(endpoint_url) -# Uncomment the below line to see SOAP wiredumps. -# obj.wiredump_dev = STDERR +# run ruby with -d to see SOAP wiredumps. +obj.wiredump_dev = STDERR if $DEBUG __EOD__ @definitions.porttype(name).operations.each do |operation| diff --git a/lib/wsdl/soap/complexType.rb b/lib/wsdl/soap/complexType.rb index bba50fd153..b2e13d0564 100644 --- a/lib/wsdl/soap/complexType.rb +++ b/lib/wsdl/soap/complexType.rb @@ -106,18 +106,43 @@ class ComplexType < Info end end if check_array_content(complexcontent.content) - return complexcontent.content.elements[0].type + return element_simpletype(complexcontent.content.elements[0]) end elsif check_array_content(content) - return content.elements[0].type + return element_simpletype(content.elements[0]) end raise RuntimeError.new("Assert: Unknown array definition.") end + def find_aryelement + unless compoundtype == :TYPE_ARRAY + raise RuntimeError.new("Assert: not for array") + end + if complexcontent + if check_array_content(complexcontent.content) + return complexcontent.content.elements[0] + end + elsif check_array_content(content) + return content.elements[0] + end + nil # use default item name + end + private + def element_simpletype(element) + if element.type + element.type + elsif element.local_simpletype + element.local_simpletype.base + else + nil + end + end + def check_array_content(content) - content.elements.size == 1 and content.elements[0].maxoccurs != '1' + content and content.elements.size == 1 and + content.elements[0].maxoccurs != '1' end def content_arytype diff --git a/lib/wsdl/soap/driverCreator.rb b/lib/wsdl/soap/driverCreator.rb index dd504210f1..eba7c158a2 100644 --- a/lib/wsdl/soap/driverCreator.rb +++ b/lib/wsdl/soap/driverCreator.rb @@ -69,18 +69,18 @@ Methods = [ end c.def_privatemethod("init_methods") do <<-EOD - Methods.each do |name_as, name, params, soapaction, namespace, style| - qname = XSD::QName.new(namespace, name_as) - if style == :document - @proxy.add_document_method(soapaction, name, params) - add_document_method_interface(name, params) + Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + add_document_operation(*definitions) else - @proxy.add_rpc_method(qname, soapaction, name, params) - add_rpc_method_interface(name, params) - end - if name_as != name and name_as.capitalize == name.capitalize - ::SOAP::Mapping.define_singleton_method(self, name_as) do |*arg| - __send__(name, *arg) + add_rpc_operation(*definitions) + qname = definitions[0] + name = definitions[2] + if qname.name != name and qname.name.capitalize == name.capitalize + ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg| + __send__(name, *arg) + end end end end diff --git a/lib/wsdl/soap/methodDefCreator.rb b/lib/wsdl/soap/methodDefCreator.rb index f256b42451..f3ffadbe69 100644 --- a/lib/wsdl/soap/methodDefCreator.rb +++ b/lib/wsdl/soap/methodDefCreator.rb @@ -46,18 +46,18 @@ class MethodDefCreator def collect_rpcparameter(operation) result = operation.inputparts.collect { |part| collect_type(part.type) - param_set(::SOAP::RPC::SOAPMethod::IN, rpcdefinedtype(part), part.name) + param_set(::SOAP::RPC::SOAPMethod::IN, part.name, rpcdefinedtype(part)) } outparts = operation.outputparts if outparts.size > 0 retval = outparts[0] collect_type(retval.type) - result << param_set(::SOAP::RPC::SOAPMethod::RETVAL, - rpcdefinedtype(retval), retval.name) + result << param_set(::SOAP::RPC::SOAPMethod::RETVAL, retval.name, + rpcdefinedtype(retval)) cdr(outparts).each { |part| collect_type(part.type) - result << param_set(::SOAP::RPC::SOAPMethod::OUT, rpcdefinedtype(part), - part.name) + result << param_set(::SOAP::RPC::SOAPMethod::OUT, part.name, + rpcdefinedtype(part)) } end result @@ -66,12 +66,12 @@ class MethodDefCreator def collect_documentparameter(operation) param = [] operation.inputparts.each do |input| - param << param_set(::SOAP::RPC::SOAPMethod::IN, - documentdefinedtype(input), input.name) + param << param_set(::SOAP::RPC::SOAPMethod::IN, input.name, + documentdefinedtype(input), elementqualified(input)) end operation.outputparts.each do |output| - param << param_set(::SOAP::RPC::SOAPMethod::OUT, - documentdefinedtype(output), output.name) + param << param_set(::SOAP::RPC::SOAPMethod::OUT, output.name, + documentdefinedtype(output), elementqualified(output)) end param end @@ -82,23 +82,38 @@ private name = safemethodname(operation.name.name) name_as = operation.name.name style = binding.soapoperation_style + inputuse = binding.input.soapbody_use + outputuse = binding.output.soapbody_use namespace = binding.input.soapbody.namespace if style == :rpc + qname = XSD::QName.new(namespace, name_as) paramstr = param2str(collect_rpcparameter(operation)) else + qname = nil paramstr = param2str(collect_documentparameter(operation)) end if paramstr.empty? paramstr = '[]' else - paramstr = "[\n" << paramstr.gsub(/^/, ' ') << "\n ]" + paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]" end - return <<__EOD__ -[#{dq(name_as)}, #{dq(name)}, + definitions = <<__EOD__ +#{ndq(binding.soapaction)}, + #{dq(name)}, #{paramstr}, - #{ndq(binding.soapaction)}, #{ndq(namespace)}, #{sym(style.id2name)} -] + { :request_style => #{sym(style.id2name)}, :request_use => #{sym(inputuse.id2name)}, + :response_style => #{sym(style.id2name)}, :response_use => #{sym(outputuse.id2name)} } __EOD__ + if style == :rpc + return <<__EOD__ +[ #{qname.dump}, + #{definitions}] +__EOD__ + else + return <<__EOD__ +[ #{definitions}] +__EOD__ + end end def rpcdefinedtype(part) @@ -144,8 +159,22 @@ __EOD__ end end - def param_set(io_type, type, name) - [io_type, type, name] + def elementqualified(part) + if mapped = basetype_mapped_class(part.type) + false + elsif definedtype = @simpletypes[part.type] + false + elsif definedtype = @elements[part.element] + definedtype.elementform == 'qualified' + elsif definedtype = @complextypes[part.type] + false + else + raise RuntimeError.new("part: #{part.name} cannot be resolved") + end + end + + def param_set(io_type, name, type, ele = nil) + [io_type, name, type, ele] end def collect_type(type) @@ -161,7 +190,12 @@ __EOD__ def param2str(params) params.collect { |param| - "[#{dq(param[0])}, #{dq(param[2])}, #{type2str(param[1])}]" + io, name, type, ele = param + unless ele.nil? + "[#{dq(io)}, #{dq(name)}, #{type2str(type)}, #{ele2str(ele)}]" + else + "[#{dq(io)}, #{dq(name)}, #{type2str(type)}]" + end }.join(",\n") end @@ -173,6 +207,15 @@ __EOD__ end end + def ele2str(ele) + qualified = ele + if qualified + "true" + else + "false" + end + end + def cdr(ary) result = ary.dup result.shift diff --git a/lib/wsdl/soap/standaloneServerStubCreator.rb b/lib/wsdl/soap/standaloneServerStubCreator.rb index 243ac12216..0b751b5153 100644 --- a/lib/wsdl/soap/standaloneServerStubCreator.rb +++ b/lib/wsdl/soap/standaloneServerStubCreator.rb @@ -55,12 +55,12 @@ Methods = [ <<-EOD super(*arg) servant = #{class_name}.new - #{class_name}::Methods.each do |name_as, name, param_def, soapaction, namespace, style| - if style == :document - @router.add_document_operation(servant, soapaction, name, param_def) + #{class_name}::Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + @router.add_document_operation(servant, *definitions) else - qname = XSD::QName.new(namespace, name_as) - @router.add_rpc_operation(servant, qname, soapaction, name, param_def) + @router.add_rpc_operation(servant, *definitions) end end self.mapping_registry = #{class_name}::MappingRegistry |