SOAP-запрос с Python-запросами - ошибка аутентификации - PullRequest
0 голосов
/ 23 октября 2018

Я пытался сделать запрос к SOAP-клиенту, но получаю ошибку аутентификации.

import requests
url="https://10.xx.xx.xx:443/ws/auth.asmx"

headers = {'content-type': 'application/soap+xml'}
body = """<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://authws.worldsys.com.ar/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<aut:AuthenticateUser>
<!--Optional:-->
<aut:username>xxxxxxxxxx</aut:username>
<!--Optional:-->
<aut:password>xxxxxxxx</aut:password>
</aut:AuthenticateUser>
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope>"""

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

Записать ответ с ошибкой

requests.exceptions.SSLError: HTTPSConnectionPool(host='10.xx.xx.xx', port=443): Max retries exceeded with url: /ws/auth.asmx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')))

Запрос работает правильнокогда сделано с SoapUI

Запрос сделан в SoapUI

Ответ от SoapUI

Я получаю ответ при использованииэтот код с общедоступным веб-сервисом, который не требует аутентификации.например,

import requests
url="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"

headers = {'content-type': 'text/xml'}
body = """<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://ws.cdyne.com/WeatherWS/" 
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body><ns0:GetWeatherInformation/></ns1:Body>
</SOAP-ENV:Envelope>"""

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