Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #270 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

respect ruby namespaces

Reported by: thentschel@autoscout24.de Assigned to: nahi
Priority: normal Milestone: 1.5.6
Component: soap4r Version: 1.5
Keywords: Cc:

Description

I want to use multiple wsdls with conflicting class definitions, so i am forced to stuff all classes of one wsdl in a module. Here's my patch so that soap4r respects ruby namespaces:

Index: soap4r-1_5_5/lib/soap/rpc/proxy.rb =================================================================== --- soap4r-1_5_5/lib/soap/rpc/proxy.rb (revision 3915) +++ soap4r-1_5_5/lib/soap/rpc/proxy.rb (working copy) @@ -31,6 +31,7 @@

attr_accessor :generate_explicit_type attr_reader :headerhandler attr_reader :streamhandler

+ attr_accessor :ruby_namespace

attr_accessor :mapping_registry attr_accessor :literal_mapping_registry

Index: soap4r-1_5_5/lib/soap/rpc/driver.rb =================================================================== --- soap4r-1_5_5/lib/soap/rpc/driver.rb (revision 3915) +++ soap4r-1_5_5/lib/soap/rpc/driver.rb (working copy) @@ -68,6 +68,7 @@

attr_reader :proxy attr_reader :options attr_accessor :soapaction

+ attr_accessor :ruby_namespace

def inspect

"#<#{self.class}:#{@proxy.inspect}>"

@@ -105,12 +106,15 @@

optionsprotocol.wiredump_file_base? = wiredump_file_base

end

- def initialize(endpoint_url, namespace = nil, soapaction = nil) + def initialize(endpoint_url, namespace = nil, soapaction = nil, ruby_namespace = nil)

@namespace = namespace @soapaction = soapaction @options = setup_options @wiredump_file_base = nil @proxy = Proxy.new(endpoint_url, @soapaction, @options)

+ @ruby_namespace = (!ruby_namespace && self.class.respond_to?(:parents)) ? self.class.parents[0] : ruby_namespace + @proxy.ruby_namespace = @ruby_namespace + @proxy.literal_mapping_registry.ruby_namespace = @ruby_namespace

end

def loadproperty(propertyname)

Index: soap4r-1_5_5/lib/soap/mapping/wsdlliteralregistry.rb =================================================================== --- soap4r-1_5_5/lib/soap/mapping/wsdlliteralregistry.rb (revision 3916) +++ soap4r-1_5_5/lib/soap/mapping/wsdlliteralregistry.rb (working copy) @@ -22,6 +22,7 @@

attr_reader :definedtypes attr_accessor :excn_handler_obj2soap attr_accessor :excn_handler_soap2obj

+ attr_accessor :ruby_namespace

def initialize(definedtypes = XSD::NamedElements::Empty,

definedelements = XSD::NamedElements::Empty)

@@ -255,10 +256,15 @@

obj

end

+ def class_from_name(name) + obj_class = Mapping.class_from_name(name) + obj_class = Mapping.class_from_name("#{@ruby_namespace.to_s}::#{name}") if (@ruby_namespace && !obj_class) ; obj_class + end +

def any2obj(node, obj_class = nil)

unless obj_class

typestr = XSD::CodeGen::GenSupport?.safeconstname(node.elename.name)

- obj_class = Mapping.class_from_name(typestr) + obj_class = class_from_name(typestr)

end if obj_class and obj_class.class_variables.include?('@@schema_element')

soapele2stubobj(node, obj_class)

@@ -293,7 +299,7 @@

item = elements.find { |k, v| k.name == name } if item

elename, class_name = item

- if klass = Mapping.class_from_name(class_name) + if klass = class_from_name(class_name)

# klass must be a SOAPBasetype or a class if klass.ancestors.include?(::SOAP::SOAPBasetype)

if value.respond_to?(:data)

@@ -333,7 +339,7 @@

attributes.each do |qname, class_name|

attr = node.extraattr[qname] next if attr.nil? or attr.empty?

- klass = Mapping.class_from_name(class_name) + klass = class_from_name(class_name)

if klass.ancestors.include?(::SOAP::SOAPBasetype)

child = klass.new(attr).data

else

Change History

10/02/06 17:56:26 changed by nahi

Thank you for the patch. It's good to know someone except me is watching source code of soap4r. :-)

I put the plan in practice that letting soap4r not depends on dynamic class name lookup. I moved @@schema_* things from generated classdef file to newly generated mappingRegistry file, and let mapping registries map soap <-> class along to the definition as far as possible. Class name lookup is the last fallback now. (#175)

I'm afraid I cannot apply your patch but I surely want to deal with the problem you encountered. Please try the repository code and let me know if it won't work. I'll post the new snapshot tarball tonight (6 or so hours later).

10/03/06 23:31:05 changed by nahi

  • status changed from new to closed.
  • resolution set to fixed.

fixed in [1731].

from soap4r-ML

********* *BEGIN ENCRYPTED or SIGNED PART* *********

Hi,

Sorry for late reply.

thentschel wrote:
> > Now, I need to stuff the soap classes (i've got multiple ones,
> > generated from different wsdl) into my rails project. Since a whole lot
> > of classes are needed for that, I definately have to put them away into
> > seperate modules, one module for each wsdl interface. But here comes
> > the headache: the soap mapping simply doesn't understand this concept,
> > it cannot find the classes even if they're in the same namespace as the
> > driver-class. As a result, I can still do the soap calls, but the
> > returning collection contains only strings...

Soap4r tried to find a class with given typename String from top level
binding, not from the class where a driver is located.

I put the plan in practice that letting soap4r not depends on dynamic
class name lookup.  I moved @@schema_* things from generated classdef
file to newly generated mappingRegistry file, and let mapping registries
map soap <-> class along to the definition as far as possible.  Class
name lookup is the last fallback now.
http://dev.ctor.org/soap4r/ticket/175

I'm afraid I cannot apply your patch but I surely want to deal with the
problem you encountered.  Please try the repository code and let me know
if it won't work.  I'll post the new snapshot tarball tonight (6 or so
hours later).

Regards,
// NaHi


********** *END ENCRYPTED or SIGNED PART* **********

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "soap4r" group.
To post to this group, send email to soap4r@googlegroups.com
To unsubscribe from this group, send email to soap4r-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/soap4r
-~----------~----~----~----~------~----~------~--~---

10/03/06 23:31:17 changed by nahi

  • milestone changed from undefined to 1.5.6.