Closed FrugoFruit90 closed 8 years ago
Element.nsmap is readonly, see for example:
>>> from lxml import etree
>>> foo = etree.Element('foo')
>>> etree.tostring(foo)
b'<foo/>'
>>> foo.nsmap
{}
>>> foo.nsmap['x'] = 'http://example.org'
>>> foo.nsmap
{}
Is there a different way in which I should make changes like adding a custom namespace that is undefined in the wsdl but required by the server? Or is such functionality unsupported at the moment?
Well zeep uses lxml for the xml generation. So it needs to be supported by lxml. You can register a custom prefix via etree.register_namespace() but then you still need to add an element with that namespace in order to get it in the xml. Not sure how, it's a bit out of scope of zeep i'm afraid.
Perhaps you can workaround it by adding an header element with that namespace and hoping that your server ignores it?
Closing for now (trying to keep the number of open issues limited)
I need to add a custom namespace to the XML that I send to the server (wsdl is in the code). I tried to do it similarly as I would with suds, i.e. by using a message plugin. Unfortunately, nothing happens. the envelope stays the same. In fact, when I run the code in debug mode I could see that the envelope was never once modified even directly after the line that is supposed to add a namespace. Below is the code that reproduces this:
And here is the the XML that is being sent, courtesy of the logger (I set it up as in the documentation):
As you can see, there is no
xmlns:n11="http://www.nfz.gov.pl/xml/prkus/sso/drukuj-karte/v3.0"
in the resulting XML. Any idea what is wrong here?As always, I will be more than happy to provide additional information and perform any necessary tests. Cheers!