Pyhton - 从 Python 调用带有 WSDL、有效负载和基本身份验证的 SOAP API
我正在尝试使用 WSDL 调用 SOAP API、请求 PAYLOAD、使用 Python 中的用户名和密码进行基本身份验证。
下面给出了代码 spinet。但无法进行身份验证,但 SOAPUI 中可以使用相同的用户名和密码。 回复还包含一个附件。 帮助我如何通过一些示例代码获取该附件。
import base64
import requests
from requests.structures import CaseInsensitiveDict
from requests.auth import HTTPBasicAuth
url = "https://WSDL URL"
headersVal = CaseInsensitiveDict()
headersVal["Content-Type"] = "application/soap+xml"
headersVal["Authorization"] = 'Basic %s' % base64.b64encode("username:password")
data = """request Payload"""
resp = requests.post(url, headers=headersVal, data=data)
print(resp.status_code)
谢谢 安尼什
I am attempting to call SOAP API with WSDL, request PAYLOAD, basic authentication using user name and password from Python.
Code spinet is given below. But it is failing to authenticate but same user name and password is working in SOAPUI.
Also response contain one attachment.
Help me how to get that attachment with some example code.
import base64
import requests
from requests.structures import CaseInsensitiveDict
from requests.auth import HTTPBasicAuth
url = "https://WSDL URL"
headersVal = CaseInsensitiveDict()
headersVal["Content-Type"] = "application/soap+xml"
headersVal["Authorization"] = 'Basic %s' % base64.b64encode("username:password")
data = """request Payload"""
resp = requests.post(url, headers=headersVal, data=data)
print(resp.status_code)
Thanks
Anish
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用此。如果这不起作用,请让我知道错误。
Try using this. If this doesn't work let me know the error.