mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 586 forks source link

How to user Zeep with web debugging proxies #1225

Open felipeferri opened 3 years ago

felipeferri commented 3 years ago

I've been using zeep in one of my projects. When working with web apis i usually monitor my app communications using Charles Proxy, which is a web debugging proxy, so it is much easier to debug the requests and responses.

If I try to use Charles with zeep, the soap requests fail immediately because zeep won't recognize the self-signed SSL certificate issued by Charles. This happens in general when using the requests module, and in order to fix this it is necessary to set verify=False on the Session object used on the requests.

I finally found out how to configure the Session object on zeep. This was not obvious and, as far as I am able to tell, it isn't on the documentation, so I suggest you insert a small section on the docs on how to configure the session.

This is how it is done. When creating a Client, we must specify a custom Transport object. The Transport object contains the requests.Session object used for communicating with the service provider. We can configure the Session object as we desire.

` from zeep.transport import Transport from zeep.client import Client

transport = Transport() transport.session.verify = False

client = zeep.Client(wsdl=wsdl, transport=transport) `

With this, requests made to client now can be sniffed by Charles.