'Pyhton - Call SOAP API with WSDL, payload and basic authentication from Python
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
