Python XML请求的用户名密码令牌失败

2024-05-19 10:09:21 发布

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

我正在执行一个重新查询登录和密码验证的XML请求,并且从服务器收到以下响应:用户名密码令牌的身份验证失败

我会做错什么?在

提前谢谢。在

import requests

url = "https://webserverexemple.com"

headers = {'content-type': 'application/soap+xml'}

form =  """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http:webserverexemple.com">
<soapenv:Header>
  <wsse:Security xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
     <wsse:UsernameToken wsu:Id="UsernameToken">
        <wsse:Username>LOGIN</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASS</wsse:Password>
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">D8Nl8KdFWD59Qh4R6zSIsA==</wsse:Nonce>
        <wsu:Created>YYYY-04-25T01:57:05.111Z</wsu:Created>
     </wsse:UsernameToken>
  </wsse:Security>
</soapenv:Header>
<soapenv:Body>
  <dat:methodexemple>
     <parameters>
        <par1>var1</par1>
        <returnexemple>
           <par2>true</par2>
           <par3>true</par3>
        </returnexemple>
     </parameters>
  </dat:methodexemple>
</soapenv:Body>
 </soapenv:Envelope>"""


   response = requests.post(url=url,data=form,headers=headers).content

Tags: orghttpurldocsopensoapdatheaders

热门问题