Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zeep - disable warning "Forcing soap:address location to HTTPS"

I'm using the zeep package to access some API on https, and on every connection it prints out a warning (to stderr):

Forcing soap:address location to HTTPS

Some searching I did turned up that the line responsible is this, which implies that this the result of the logging level of the module. Changing the log level seems to require editing this file.

This is a bad solution for me because I want to be able to turn this warning off at run time, because the app using this package will be a frozen app (an exe).

If that's relevant, these are the minimum lines required to display that warning (although obviously, the domain here is a fictional one, and so are the user and password):

import zeep
client = zeep.CachingClient('https://api.somedomain.com/Services/ApiService.svc?singleWsdl')
client.service.VerifyLogin('user', 'pass')

I know zeep clients can be set to not force https, but I assume that would make the connection less secure? (after all, I'm passing usernames and passwords as clear text without https)

like image 253
Ofer Sadan Avatar asked Nov 01 '19 16:11

Ofer Sadan


1 Answers

After a few days of research I've finally been able to solve this on my own. I didn't realize logging levels can be changed from imported modules. I added this line at the start of my code (after imports) and it fixed the issue:

import logging
logging.getLogger('zeep').setLevel(logging.ERROR)

Hope this helps other people that encounter the same problem

like image 162
Ofer Sadan Avatar answered Sep 21 '22 06:09

Ofer Sadan