Python Zeep中格式良好的文档中需要根元素

2024-06-17 14:58:45 发布

您现在位置:Python中文网/ 问答频道 /正文

试图使用Python的Zeep包调用专有服务,因为它是专有的,我不能给出WSDL URL,我们必须签署协议

from zeep.wsse.username import UsernameToken
from zeep import Client

client = Client('http://IP/<PATH>?<filename>.wsdl', wsse=UsernameToken('Username', 'Password'))


client.service.serviceName(param={'param': 1}, param2={'param2': 2}, param3={'param3': 3})

Fault: org.xml.sax.SAXParseException: The root element is required in a well-formed document. Message being parsed: 

生成的XML

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken>
        <wsse:Username>USERNAME</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </soap-env:Header>
  <soap-env:Body>
    <ns0:proprietary xmlns:ns0="URL">
      <details>
        <proprietary>ACODE</proprietary>
        <proprietary>CID</proprietary>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary>A</proprietary>
        <proprietary>N</proprietary>
        <proprietary>VAL</proprietary>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary>SAHIL</proprietary>
        <proprietary>SHUKLA</proprietary>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary>01</proprietary>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      </details>
      <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      <profile>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary>1000.0</proprietary>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <proprietary>T</cycleType>
        <proprietary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      </profile>
      <proprietary>true</proprietary>
      <proprietary>true</proprietary>
    </ns0:proprietary>
  </soap-env:Body>
</soap-env:Envelope>

Tags: instanceorgenvtruehttpwwwsoapxmlschema