Making a SOAP request using Python requests module

前端 未结 4 1120
滥情空心
滥情空心 2021-02-06 14:48

I used python requests module for REST requests.

I am trying to make a soap request but I wondered couldn’t get an example for this . Here is My soap body and headers.

4条回答
  •  滥情空心
    2021-02-06 15:04

    This is largely hypothetical since I'm not aware of anyone actually having implemented it but suds supports making custom implementations of suds.transport.Transport. Once such is suds.transport.http.HttpTransport. So technically by implementing a transport subclass you could create a suds transport that uses requests.

    http://jortel.fedorapeople.org/suds/doc/suds.transport.http.HttpTransport-class.html is what's used by default and it returns http://jortel.fedorapeople.org/suds/doc/suds.transport.Reply-class.html so as you can see, it should be fairly simple to wrap requests replies so that suds understands them. Transport request (that should be sent with requests) is documented here http://jortel.fedorapeople.org/suds/doc/suds.transport.Request-class.html I might sooner or later implement this if no one beets me to it

    Why all this effort? Because suds uses urllib2 internally which is far inferior to python-requests as a HTTP client implementation.

    Yet one more edit: I made a gist available as a starting point https://gist.github.com/nanonyme/6268358 . It's MIT code and untested but should work as a starting point for the transport.

提交回复
热议问题