SOAP 1.2 python client

前端 未结 4 855
别跟我提以往
别跟我提以往 2020-12-31 06:40

I am looking for a python SOAP 1.2 client but it seems that it does not exist . All of the existing clients are either not maintainted or only compatible with SOAP 1.1:

4条回答
  •  清歌不尽
    2020-12-31 07:26

    Even though this question has an accepted answer, there's a few notes I'd like regarding suds.

    I'm currently writing some code for interfacing with .tel community hosting for work and I needed a Python SOAP library, and suds was pretty much ideal except for its lack of support for SOAP 1.2.

    I managed to hack around the problem as for my purposes, SOAP 1.1 and SOAP 1.2 share enough in common that I was able to simply patch suds to use the SOAP 1.2 envelope namespace. I outlined what I did in this gist: https://gist.github.com/858851

    As it's worth reproducing here, here's the code:

    from suds.client import Client
    from suds.bindings import binding
    import logging
    
    
    USERNAME = 'username'
    PASSWORD = 'password'
    
    # Just for debugging purposes.
    logging.basicConfig(level=logging.INFO)
    logging.getLogger('suds.client').setLevel(logging.DEBUG)
    
    # Telnic's SOAP server expects a SOAP 1.2 envelope, not a SOAP 1.1 envelope
    # and will complain if this hack isn't done.
    binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope')
    client = Client('client.wsdl',
        username=USERNAME,
        password=PASSWORD,
        headers={'Content-Type': 'application/soap+xml'})
    
    # This will now work just fine.
    client.service.someRandomMethod()
    

    If I've time, I'm planning on submitting a patch to suds to allow the version of SOAP to be used to be specified, and to add enough missing functionality to make it useful.

提交回复
热议问题