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

Changeset 1897

Show
Ignore:
Timestamp:
07/21/07 13:36:04 (1 year ago)
Author:
nahi
Message:
  • choice handling bug fixed according to a patch from KR, Vesa Varimo. If there was choice element in complex type, soap4r didn't process all elements if the first element was an empty array. closes #382.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/mapping/literalregistry.rb

    r1871 r1897  
    175175        else 
    176176          if child.respond_to?(:each) and definition.as_array? 
    177             child.each do |item| 
    178               ele.add(definedobj2soap(item, definition)) 
     177            if child.empty? 
     178              added = false 
     179            else 
     180              child.each do |item| 
     181                ele.add(definedobj2soap(item, definition)) 
     182              end 
    179183            end 
    180184          else 
  • trunk/test/wsdl/choice/choice.wsdl

    r1790 r1897  
    2727            <xsd:element name="C2" type="xsd:string"/> 
    2828          </xsd:sequence> 
     29        </xsd:sequence> 
     30      </xsd:complexType> 
     31 
     32      <xsd:complexType name="emptyArrayAtFirst"> 
     33        <xsd:sequence> 
     34          <xsd:choice> 
     35            <xsd:element name="A" maxOccurs="unbounded" type="xsd:string"/> 
     36            <xsd:element name="B1" type="xsd:string"/> 
     37            <xsd:element name="B2" type="xsd:string"/> 
     38          </xsd:choice> 
    2939        </xsd:sequence> 
    3040      </xsd:complexType> 
     
    7080        </xsd:complexType> 
    7181      </xsd:element> 
     82 
     83      <xsd:element name="echoele_complex_emptyArrayAtFirst"> 
     84        <xsd:complexType> 
     85          <xsd:sequence> 
     86            <xsd:element name="data" type="tns:emptyArrayAtFirst"/> 
     87          </xsd:sequence> 
     88        </xsd:complexType> 
     89      </xsd:element> 
    7290    </xsd:schema> 
    7391  </types> 
     
    85103    <part name="parameters" element="tns:echo_complex_response" /> 
    86104  </message> 
     105  <message name="echo_complex_emptyArrayAtFirst_in"> 
     106    <part name="parameters" element="tns:echoele_complex_emptyArrayAtFirst" /> 
     107  </message> 
     108  <message name="echo_complex_emptyArrayAtFirst_out"> 
     109    <part name="parameters" element="tns:echoele_complex_emptyArrayAtFirst" /> 
     110  </message> 
    87111 
    88112  <portType name="choice_porttype"> 
     
    95119      <input message="tns:echo_complex_in" /> 
    96120      <output message="tns:echo_complex_out" /> 
     121    </operation> 
     122 
     123    <operation name="echo_complex_emptyArrayAtFirst"> 
     124      <input message="tns:echo_complex_emptyArrayAtFirst_in" /> 
     125      <output message="tns:echo_complex_emptyArrayAtFirst_out" /> 
    97126    </operation> 
    98127  </portType> 
     
    119148      </output> 
    120149    </operation> 
     150 
     151    <operation name="echo_complex_emptyArrayAtFirst"> 
     152      <soap:operation soapAction="urn:choice:echo_complex_emptyArrayAtFirst" style="document" /> 
     153      <input> 
     154        <soap:body use="literal" /> 
     155      </input> 
     156      <output> 
     157        <soap:body use="literal" /> 
     158      </output> 
     159    </operation> 
    121160  </binding> 
    122161 
  • trunk/test/wsdl/choice/test_choice.rb

    r1794 r1897  
    2929        XSD::QName.new(Namespace, 'echo_complex_response') 
    3030      ) 
     31      add_document_method( 
     32        self, 
     33        Namespace + ':echo_complex_emptyArrayAtFirst', 
     34        'echo_complex_emptyArrayAtFirst', 
     35        XSD::QName.new(Namespace, 'echoele_complex_emptyArrayAtFirst'), 
     36        XSD::QName.new(Namespace, 'echoele_complex_emptyArrayAtFirst') 
     37      ) 
    3138      @router.literal_mapping_registry = ChoiceMappingRegistry::LiteralRegistry 
    3239    end 
     
    3845    def echo_complex(arg) 
    3946      Echo_complex_response.new(arg.data) 
     47    end 
     48 
     49    def echo_complex_emptyArrayAtFirst(arg) 
     50      arg 
    4051    end 
    4152  end 
     
    7889    gen.opt['force'] = true 
    7990    gen.run 
    80     TestUtil.require(DIR, 'choiceMappingRegistry.rb', 'choice.rb') 
     91    TestUtil.require(DIR, 'choiceDriver.rb', 'choiceMappingRegistry.rb', 'choice.rb') 
    8192  end 
    8293 
     
    178189    assert_equal("C2", ret.data.c2) 
    179190  end 
     191 
     192  def test_stub_emptyArrayAtFirst 
     193    @client = Choice_porttype.new("http://localhost:#{Port}/") 
     194    @client.wiredump_dev = STDOUT if $DEBUG 
     195    # 
     196    arg = EmptyArrayAtFirst.new 
     197    arg.b1 = "b1" 
     198    ret = @client.echo_complex_emptyArrayAtFirst(arg) 
     199    assert_nil(ret.a) 
     200    assert_equal("b1", ret.b1) 
     201    assert_nil(ret.b2) 
     202  end 
    180203end 
    181204