I got bitten by this again. My program wants to talk to several
different SOAP services and a couple of them are very picky about the
SOAP-ENV. Worse, they don't use the same SOAP-ENV.
This patch allows suds to pick up the SOAP-ENV from the WSDL, iff it
is defined as a namespace prefix in the root of the document.
I'm no XML and/or WSDL expert, so this fix may or may not work for
you. It happens to work for me. This patch is based on suds-0.3.7.
--Chris
--- C:/src/suds/suds/bindings/binding.py (revision 5)
+++ C:/src/suds/suds/bindings/binding.py (revision 337)
@@ -67,6 +67,10 @@
self.options = Options()
self.parser = Parser()
self.multiref = MultiRef()
+ self.envns = envns
+ ns = wsdl.root.nsprefixes.get('SOAP-ENV')
+ if ns:
+ self.envns = ('SOAP-ENV', ns)
def unmarshaller(self, typed=True):
"""
@@ -289,7 +293,7 @@
@return: The soap envelope containing the body and header.
@rtype: L{Element}
"""
- env = Element('Envelope', ns=envns)
+ env = Element('Envelope', ns=self.envns)
env.addPrefix(Namespace.xsins[0], Namespace.xsins[1])
env.append(header)
env.append(body)
@@ -303,7 +307,7 @@
@return: the soap body fragment.
@rtype: L{Element}
"""
- header = Element('Header', ns=envns)
+ header = Element('Header', ns=self.envns)
header.append(content)
return header
@@ -382,7 +386,7 @@
@return: the soap body fragment.
@rtype: L{Element}
"""
- body = Element('Body', ns=envns)
+ body = Element('Body', ns=self.envns)
body.append(content)
return body
@@ -503,4 +507,4 @@
return self
else:
return self.__resolved
-
\ No newline at end of file
+
On Tue, Aug 25, 2009 at 11:44 AM, Michael Sommerville
<msommerville(a)gmail.com> wrote:
On Mon, Aug 24, 2009 at 11:55 PM, Chris
Frantz<frantzcj(a)gmail.com> wrote:
> Hello,
>
> It appears that the soap envelope namespace is hardcoded to
> 'http://schemas.xmlsoap.org/soap/envelope/' in binding.py. I'm trying
to
> talk to a gSOAP based web service that insists the envelope namespace be
> 'http://www.w3.org/2003/05/soap-envelope'.
>
> Unfortunately, I don't have permission to share the WSDL file.
>
> Any suggestions?
We have the same issue with our gSOAP service. I'm sure there are
other cleaner ways of achieving the same result, but what about simply
replacing the envns object before you make any calls to the web
service? For example:
suds.bindings.binding.envns = ('SOAP-ENV',
'http://www.w3.org/2003/05/soap-envelope')
-Mike