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

Ticket #408 (new defect)

Opened 1 year ago

Last modified 1 year ago

class name crash for the same name in different targetNamespaces

Reported by: nahi Assigned to: nahi
Priority: high Milestone: 1.6.1
Component: wsdl4r Version: 1.5
Keywords: Cc:

Description

from soap4r-ml

Hello,

On 3 Zář, 15:39, "NAKAMURA, Hiroshi" <nakah...@sarion.co.jp> wrote:
> >
> > Leoš Bitto wrote:
>> > > Well, I have just upgraded to soap4r 1.5.7.90.20070831 and it seems
>> > > that this issue is still not solved completely - I still get the
>> > > warning "cannot find mapped class: Entry". Here is the relevant part
>> > > of the schema:
> >
> > Thank you very much for trying RC.  Anonymous class support was
> > incomplete about Array.  I reopened #355 and have fixed now.
> >
> > Would you please try it?

Sure, thanks for the fix. At the first sight it looks promising - this
is generated now:

class ExtraInfo < ::Array

  class Entry
    attr_accessor :key
    attr_accessor :value

    def initialize(key = nil, value = nil)
      @key = key
      @value = value
    end
  end
end

So I have tried to use it this way:

entry=ExtraInfo::Entry.new(SOAP::SOAPString.new('key1'),SOAP::SOAPString.new('value1'))

and bummer:

in `initialize': wrong number of arguments (2 for 0) (ArgumentError)

Am I mad or what? It should have two arguments! Or not? After some
investigation not, because in a different XML schema (with a different
XML namespace) there is an element cleverly named ExtraInfo, too.
Unfortunatelly wsdl2ruby does not handle this situation correctly now
and just redefines (reopens) the above mentioned class. This is the
part of the other XML schema:

  <xs:element name="ExtraInfo">
    <xs:annotation>
      <xs:documentation> A particular solution specific information.</
xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="Entry">
          <xs:annotation>
            <xs:documentation>An actual value of the extra info item.</
xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="Key" type="xs:string"
use="required">
                  <xs:annotation>
                    <xs:documentation>An identification of the extra
info item.</xs:documentation>
                  </xs:annotation>
                </xs:attribute>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="unique_key">
      <xs:annotation>
        <xs:documentation>Unique constraint. The attribute Key must be
unique.</xs:documentation>
      </xs:annotation>
      <xs:selector xpath="msg:Entry"/>
      <xs:field xpath="@Key"/>
    </xs:unique>
  </xs:element>

and this is how wsdl2ruby reopens the above mentioned class:

class ExtraInfo < ::Array

  #   xmlattr_Key - SOAP::SOAPString
  class Entry
    AttrKey = XSD::QName.new(nil, "Key")

    def __xmlattr
      @__xmlattr ||= {}
    end

    def xmlattr_Key
      __xmlattr[AttrKey]
    end

    def xmlattr_Key=(value)
      __xmlattr[AttrKey] = value
    end

    def initialize
      @__xmlattr = {}
    end
  end
end

No arguments for initialize() here, so the ArgumentError makes sense
now. Another fix to properly distinguish elements from complexTypes
needed? And maybe the same names in different XML namespaces should be
considered, too...


Leoš Bitto

Change History

09/07/07 00:10:53 changed by nahi

  • priority changed from normal to high.
  • component changed from soap4r to wsdl4r.
  • milestone changed from 1.5.8 to undefined.

In [1939]: added wsdl/soap/classNameCreator and let it handle whole classname creation. and when the same NCName is used in different namespaces, ClassNameCreator? tries to avoid classname crash by adding '_' at the end of classname. it's a dirty workaround for #408 and will be changed in the future.

09/07/07 21:59:32 changed by nahi

  • milestone changed from undefined to 1.6.0.