Python SOAP client with Zeep - authentication

前端 未结 3 1320
臣服心动
臣服心动 2020-12-28 10:58

I am trying to use Zeep to implement a SOAP client, as it seems the only maintained library at the moment:

  • ZSI looked very good but its latest
3条回答
  •  不知归路
    2020-12-28 11:36

    Probably with the newer Version of zeep the older solution does not work anymore. Here is the new way:

    from requests.auth import HTTPBasicAuth  # or HTTPDigestAuth, or OAuth1, etc.
    from requests import Session
    from zeep import Client
    from zeep.transports import Transport
    
    session = Session()
    session.auth = HTTPBasicAuth(user, password)
    client = Client('http://my-endpoint.com/production.svc?wsdl',
                transport=Transport(session=session))
    

提交回复
热议问题