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

{5} Assigned, Active Tickets by Owner (Full Description) (1 matches)

List tickets assigned, group by ticket owner. This report demonstrates the use of full-row display.

nahi

Ticket Summary Component Milestone Type Severity Created
Description
#447 LiteralRegistry#add_elesoap2stubobj tries to call two-result version of SOAPArray#each soap4r 1.5.9 defect normal 10/17/07

soap4r 1.5.8 fails when mapping SOAP array elements to Ruby classes generated by wsdl2ruby.

The stack trace shows:

NoMethodError: undefined method `elename' for nil:NilClass
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:278:in `add_elesoap2stubobj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/baseData.rb:928:in `each'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/baseData.rb:927:in `each'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:277:in `add_elesoap2stubobj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:250:in `elesoap2stubobj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:232:in `any2obj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:305:in `elesoapchild2obj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:280:in `add_elesoap2stubobj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/baseData.rb:618:in `each'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:277:in `add_elesoap2stubobj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:250:in `elesoap2stubobj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:232:in `any2obj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/literalregistry.rb:53:in `soap2obj'
        from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/mapping/mapping.rb:150:in `_soap2obj'
[...]

The relevant lines of code in literalregistry.rb:278 are

  def add_elesoap2stubobj(node, obj, definition)
    vars = {}
    node.each do |name, value|
      item = definition.elements.find_element(value.elename)

The problem is that SOAPArray#each only yields one value on each iteration, not two:

# File soap/baseData.rb, line 652
  def each
    @data.each do |data|
      yield(data)
    end
  end

The error occurs while parsing the first Property element near the beginning of the response:

<SearchResult>
  <Properties>
    <Property Name="pageNumber">
      <Value>1</Value>
    </Property>
    <Property Name="totalReturned">
      <Value>10</Value>
    </Property>
    <Property Name="totalAvailable">
      <Value>121</Value>
    </Property>
    <Property Name="transactionId">
      <Value>test</Value>
    </Property>
    <Property Name="term">
      <Value>coffee</Value>
    </Property>
    <Property Name="zip">
      <Value>91203</Value>
    </Property>
    <Property Name="pageSize">
      <Value>10</Value>
    </Property>
  </Properties>
[...]

When the error occurs,

  • node is a SOAPArray containing the Properties element
  • obj is an empty array with the Ruby type ArrayOf_Properties
  • name is a a SOAPStruct, which contains the first Property element (with Name="pageNumber")
  • value is nil

The relevant fragment of the WSDL schema is

<xsd:complexType name="SearchResult">
        <xsd:sequence>
                <xsd:element name="Properties" nillable="true"
                        type="tns2:ArrayOf_Properties">
                </xsd:element>
                <xsd:element name="Categories" nillable="true"
                        type="tns2:ArrayOf_Categories">
                </xsd:element>
                <xsd:element name="Listings" nillable="true"
                        type="tns2:ArrayOf_Listings">
                </xsd:element>
        </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Property">
        <xsd:sequence>
                <xsd:element name="Value" type="xsd:string"
                        nillable="false" maxOccurs="1" minOccurs="0">							
                </xsd:element>
                <xsd:element name="Values" type="tns2:ArrayOf_Values" 
                        nillable="false" maxOccurs="1" minOccurs="0">
                </xsd:element>
                <xsd:element name="Record" type="tns2:ArrayOf_Properties"
                        nillable="false" maxOccurs="1" minOccurs="0">							
                </xsd:element>
                <xsd:element name="Records" type="tns2:ArrayOf_Records"
                        nillable="false" maxOccurs="1" minOccurs="0" >						
                </xsd:element>
        </xsd:sequence>
        
        <xsd:attribute name="Name" type="xsd:string">
        </xsd:attribute>
</xsd:complexType>

<xsd:complexType name="ArrayOf_Properties">
        <xsd:sequence>
                <xsd:element name="Property" type="tns2:Property"
                        nillable="true" maxOccurs="unbounded" />
        </xsd:sequence>
</xsd:complexType>

Note: See TracReports for help on using and creating reports.