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

Changeset 1949

Show
Ignore:
Timestamp:
09/10/07 21:13:35 (8 months ago)
Author:
nahi
Message:
  • do not create extraattr entry in SOAP/OM when the value is nil. it fixes unneccesary XML attribute serialization introduced in [1945].
  • let it be distinguishable <ele attr=> from <ele> (no attribute in the element). now the former returns and the latter returns nil. closes #418.
Files:

Legend:

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

    r1942 r1949  
    320320      attributes.each do |qname, class_name| 
    321321        attr = node.extraattr[qname] 
    322         next if attr.nil? or attr.empty? 
     322        next if attr.nil? 
    323323        child = attr 
    324324        if class_name 
  • trunk/lib/soap/mapping/registry.rb

    r1942 r1949  
    241241    if typedef.attributes 
    242242      typedef.attributes.each do |qname, param| 
    243         ele.extraattr[qname] = get_xmlattr_value(obj, qname) 
     243        value = get_xmlattr_value(obj, qname) 
     244        ele.extraattr[qname] = value unless value.nil? 
    244245      end 
    245246    end 
  • trunk/lib/soap/mapping/wsdlliteralregistry.rb

    r1942 r1949  
    232232    if typedef.attributes 
    233233      typedef.attributes.each do |at| 
    234         ele.extraattr[at.name] = get_xmlattr_value(obj, at.name) 
     234        value = get_xmlattr_value(obj, at.name) 
     235        ele.extraattr[at.name] = value unless value.nil? 
    235236      end 
    236237    end 
  • trunk/test/soap/test_extraattr.rb

    r1937 r1949  
    1818          Id="extraattr"></n1:headeritem> 
    1919  </env:Header> 
    20   <env:Body Id="extraattr"> 
     20  <env:Body Id="extraattr&lt;&gt;"> 
    2121    <n2:test xmlns:n2="my:foo" 
    2222        Id="extraattr"></n2:test> 
     
    3131    header.add("test", hi) 
    3232    body = SOAP::SOAPBody.new() 
    33     body.extraattr["Id"] = "extraattr
     33    body.extraattr["Id"] = "extraattr<>
    3434    bi = SOAP::SOAPElement.new(XSD::QName.new("my:foo", "bodyitem")) 
    3535    bi.extraattr["Id"] = "extraattr" 
     
    4747    assert_equal("extraattr", env.extraattr["Id"]) 
    4848    assert_equal("extraattr", header.extraattr["Id"]) 
    49     assert_equal("extraattr", body.extraattr["Id"]) 
     49    assert_equal("extraattr<>", body.extraattr["Id"]) 
    5050    assert_equal("extraattr", header["headeritem"].element.extraattr[XSD::QName.new(nil, "Id")]) 
    5151  end 
  • trunk/test/wsdl/anonymous/expectedClassDef.rb

    r1934 r1949  
    2222 
    2323# {urn:lp}loginResponse 
    24 #   loginResult - LoginResponse::LoginResult 
     24#   loginResult - WSDL::Anonymous::LoginResponse::LoginResult 
    2525class LoginResponse 
    2626 
     
    4444 
    4545# {urn:lp}login 
    46 #   loginRequest - Login::LoginRequest 
     46#   loginRequest - WSDL::Anonymous::Login::LoginRequest 
    4747class Login 
    4848 
  • trunk/test/wsdl/any/expectedEcho.rb

    r1934 r1949  
    2525# {urn:example.com:echo-type}setOutputAndCompleteRequest 
    2626#   taskId - SOAP::SOAPString 
    27 #   data - SetOutputAndCompleteRequest::C_Data 
     27#   data - WSDL::Any::SetOutputAndCompleteRequest::C_Data 
    2828#   participantToken - SOAP::SOAPString 
    2929class SetOutputAndCompleteRequest 
  • trunk/test/wsdl/document/test_rpc.rb

    r1945 r1949  
    124124    @client.wiredump_dev = STDOUT if $DEBUG 
    125125    @client.literal_mapping_registry = EchoMappingRegistry::LiteralRegistry 
    126  
     126    do_test_with_stub(@client) 
     127  end 
     128 
     129  def test_driver_stub 
     130    @client = ::WSDL::Document::Docrpc_porttype.new 
     131    @client.endpoint_url = "http://localhost:#{Port}/" 
     132    @client.wiredump_dev = STDOUT if $DEBUG 
     133    do_test_with_stub(@client) 
     134  end 
     135 
     136  def test_nil_attribute 
     137    @client = ::WSDL::Document::Docrpc_porttype.new 
     138    @client.endpoint_url = "http://localhost:#{Port}/" 
     139    @client.wiredump_dev = STDOUT if $DEBUG 
     140    struct1 = Echo_struct.new("mystring1", now1 = Time.now) 
     141    struct1.xmlattr_m_attr = nil 
     142    struct2 = Echo_struct.new("mystr<>ing2", now2 = Time.now) 
     143    struct2.xmlattr_m_attr = '' 
     144    echo = Echoele.new(struct1, struct2) 
     145    echo.xmlattr_attr_string = '' 
     146    echo.xmlattr_attr_int = nil 
     147    ret = @client.echo(echo) 
     148    # struct1 and struct2 are swapped 
     149    assert_equal('', ret.struct1.xmlattr_m_attr) 
     150    assert_equal(nil, ret.struct_2.xmlattr_m_attr) 
     151    assert_equal('', ret.xmlattr_attr_string) 
     152    assert_equal(nil, ret.xmlattr_attr_int) 
     153  end 
     154 
     155  def do_test_with_stub(client) 
    127156    struct1 = Echo_struct.new("mystring1", now1 = Time.now) 
    128157    struct1.xmlattr_m_attr = 'myattr1' 
     
    132161    echo.xmlattr_attr_string = 'attr_str<>ing' 
    133162    echo.xmlattr_attr_int = 5 
    134     ret = @client.echo(echo) 
     163    ret = client.echo(echo) 
    135164 
    136165    # struct#m_datetime in a response is a DateTime even though 
  • trunk/test/wsdl/ref/expectedProduct.rb

    r1944 r1949  
    135135#   bag - WSDL::Ref::Product 
    136136#   rating - SOAP::SOAPString 
    137 #   comment_1 - ProductBag::Comment_1 
     137#   comment_1 - WSDL::Ref::ProductBag::Comment_1 
    138138#   comment_2 - WSDL::Ref::Comment 
    139139#   m___point - WSDL::Ref::C__point