Robotframework SudsLibrary 在调用时生成附加元素 "Call Soap Method"

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

当尝试执行以下 robotscript 时,它向登录元素添加了额外的元素..

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}

原始请求格式

 <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>

生成的代码:

<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>

如何删除额外的用户名标签?

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

问题很可能是登录方法没有将其参数包装在对象中,而是直接使用。 Suds 为所有方法创建类型,但调用这些方法不需要这些。 如果您查看 Create Soap Client 的输出,您可能会看到类似 logIn(username, password) 的内容。这意味着您直接传递参数而不是在某个对象中。

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}