Send Request with API WSDL in Python

Viewed 69

Basically, I have to send a request to a API. The url is this one https://testws.punto-web.com/wcfadproc/srvproceso.svc?wsdl Information for the requests is like this, which is formatted in xml

enter image description here

The code I've tried is the following, but I get a 415 error and response is empty, so I think I mistook in request. Also, researching about this problem I've noticed that exists a module named 'zeep' that can be used for SOAP and WSDL, but not sure if it's necessary or my problem can be solved only with 'requests' module.

import requests

url = 'https://testws.punto-web.com/wcfadproc/srvproceso.svc?wsdl'
headers = {'content-type': 'text/xml'}
body =  """
<Anulacion>
<Comercio>1234567</Comercio>
<IdTxn>12345</IdTxn>
<CodAutorizacion>123456</CodAutorizacion>
<NumPedido>123456</NumPedido>
<Moneda>PEN</Moneda>
<Monto>100.00</Monto>
<FechaTxn>20211206</FechaTxn>
<HoraTxn>121212</HoraTxn>
</Anulacion>
"""

anulacion = requests.request('POST', 
                            url,
                            data= body,
                            headers = headers
                            )
0 Answers
Related