Search code examples
soapautomationrobotframeworksuds

Robotframework SudsLibrary generating additional element when it call "Call Soap Method"


When trying to execute following robotscript, it added additional element to the login element..

Library           Selenium2Library
Library           Collections
Library           String
Library           uuid
Library           Dialogs
Library           SudsLibrary


    Create Soap Client      http://xxxxxxxxx:18080/xxxxx_b/xxx?wsdl
    ${dbl array}=   Create Wsdl Object      logIn
    Set Wsdl Object Attribute   ${dbl array}    username    xxx
    Set Wsdl Object Attribute   ${dbl array}    password    xxxx
    ${result}=  Call Soap Method    logIn       ${dbl array}
    log to consol       ${result}

original request format

 <soapenv:Envelope xmlns:soapenv="http://xxxxxxxxxxxxx/x/x/" xmlns:ws="http://xxxxxxxxxxxxxxx/">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:logIn>
         <!--Optional:-->
         <username>xxx</username>
         <!--Optional:-->
         <password>xxx</password>
      </ws:logIn>
   </soapenv:Body>
</soapenv:Envelope>

Generated code :

<SOAP-ENV:Envelope xmlns:ns0="http://xxxxxxxxxxxxxx/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="h
ttp://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:logIn>
         <username>
            <username>xxx</username>
            <password>xxx</password>
         </username>
      </ns0:logIn>
   </ns1:Body>
</SOAP-ENV:Envelope>

How to remove additional username tag?

<username>
                <username>xxx</username>
                <password>xxx</password>
             </username>

Solution

  • Very likely the problem is that the login method does not take its arguments wrapped in an object, but directly. Suds creates types for all methods, but these are not needed to call the methods. If you look in the output from Create Soap Client you will probably see something like logIn(username, password). That means you pass the arguments directly and not in some object.

    Library           Selenium2Library
    Library           Collections
    Library           String
    Library           uuid
    Library           Dialogs
    Library           SudsLibrary
    
    
        Create Soap Client      http://xxxxxxxxx:18080/xxxxx_b/xxx?wsdl
        ${result}=  Call Soap Method    logIn       some_username    some_password
        log to console       ${result}