Python XML请求中的用户名密码令牌失败
我正在执行一个重新查询登录和密码身份验证的XML请求,并从服务器收到以下响应:用户名密码令牌身份验证失败 我可能做错了什么 提前谢谢Python XML请求中的用户名密码令牌失败,python,xmlhttprequest,python-requests,Python,Xmlhttprequest,Python Requests,我正在执行一个重新查询登录和密码身份验证的XML请求,并从服务器收到以下响应:用户名密码令牌身份验证失败 我可能做错了什么 提前谢谢 import requests url = "https://webserverexemple.com" headers = {'content-type': 'application/soap+xml'} form = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/so
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
导入请求
url=”https://webserverexemple.com"
headers={'content-type':'application/soap+xml'}
form=”“”
登录
通过
D8Nl8KdFWD59Qh4R6zSIsA==
YYYY-04-25T01:57:05.111Z
var1
真的
真的
"""
response=requests.post(url=url,data=form,headers=headers)。内容
我认为数据应该在字典中,意思是:键:值对,而不是整个表单xmlHi ddor254。。不幸的是没有。。它应该是一个xml请求。您可以尝试向request.post调用传递一个附加参数,requests.post(url=url,data=form,headers=headers,auth=('user','pass'))
其中包括您在SOAP正文中传递的用户名和密码。感谢Pretend程序员的重复,但它不起作用。。还有其他线索吗?我认为数据应该在字典中,意思是:键:值对,而不是整个表单xmlHi ddor254。。不幸的是没有。。它应该是一个xml请求。您可以尝试向request.post调用传递一个附加参数,requests.post(url=url,data=form,headers=headers,auth=('user','pass'))
其中包括您在SOAP正文中传递的用户名和密码。感谢Pretend程序员的重复,但它不起作用。。还有其他线索吗?