On Python 3.9, @David Ortiz answer didn't work for me, maybe something has changed. The etree_to_string
was failing to convert the XML to string.
What worked for me, instead of a plugin, I created a custom transport, that replaced the stripped tags with the correct characters, just like David's code, before the post was sent.
import zeep
from zeep.transports import Transport
from xml.etree import ElementTree
class CustomTransport(Transport):
def post_xml(self, address, envelope, headers):
message = ElementTree.tostring(envelope, encoding="unicode")
message = message.replace("<", "<")
message = message.replace(">", ">")
return self.post(address, message, headers)
client = zeep.Client('wsdl_url', transport=CustomTransport())