diff --git a/makefile b/makefile index 32a3f9e..22fc226 100644 --- a/makefile +++ b/makefile @@ -20,6 +20,7 @@ SPEC = $(PKG).spec SETUP = setup.py DOCTAR = suds-docs.tar.gz FEDORAPEOPLE = jortel@fedorapeople.org +BUILDROOT = ~/rpmbuild all : rpm docs @@ -29,10 +30,10 @@ dist : clean ./sdist python rpm : dist - cp dist/$(PKG)*.gz /usr/src/redhat/SOURCES + cp dist/$(PKG)*.gz $(BUILDROOT)/SOURCES rpmbuild -ba $(SPEC) - cp /usr/src/redhat/RPMS/noarch/$(PKG)*.rpm dist - cp /usr/src/redhat/SRPMS/$(PKG)*.rpm dist + cp $(BUILDROOT)/RPMS/noarch/$(PKG)*.rpm dist + cp $(BUILDROOT)/SRPMS/$(PKG)*.rpm dist rpmlint -i dist/$(PKG)*.rpm release : rpm rdocs @@ -61,10 +62,10 @@ clean : rm -rf build rm -rf doc rm -rf *.egg-info - rm -rf /usr/src/redhat/BUILD/$(PKG)* - rm -rf /usr/src/redhat/RPMS/noarch/$(PKG)* - rm -rf /usr/src/redhat/SOURCES/$(PKG)* - rm -rf /usr/src/redhat/SRPMS/$(PKG)* + rm -rf $(BUILDROOT)/BUILD/$(PKG)* + rm -rf $(BUILDROOT)/RPMS/noarch/$(PKG)* + rm -rf $(BUILDROOT)/SOURCES/$(PKG)* + rm -rf $(BUILDROOT)/SRPMS/$(PKG)* find . -name "*.pyc" -exec rm -f {} \; find . -name "*~" -exec rm -f {} \; diff --git a/suds/client.py b/suds/client.py index 6c84b6b..0ecea98 100644 --- a/suds/client.py +++ b/suds/client.py @@ -689,7 +689,7 @@ def headers(self): action = self.method.soap.action if isinstance(action, unicode): action = action.encode('utf-8') - stock = { 'Content-Type' : 'text/xml; charset=utf-8', 'SOAPAction': action } + stock = { 'Content-Type' : 'application/soap+xml; charset=utf-8', 'SOAPAction': action } result = dict(stock, **self.options.headers) log.debug('headers = %s', result) return result @@ -730,13 +730,12 @@ def failed(self, binding, error): status, reason = (error.httpcode, tostr(error)) reply = error.fp.read() log.debug('http failed:\n%s', reply) - if status == 500: - if len(reply) > 0: - r, p = binding.get_fault(reply) - self.last_received(r) - return (status, p) - else: - return (status, None) + if len(reply) > 0: + r, p = binding.get_fault(reply) + self.last_received(r) + return (status, p) + else: + return (status, None) if self.options.faults: raise Exception((status, reason)) else: diff --git a/suds/mx/literal.py b/suds/mx/literal.py index 937ad8e..1c5fbb0 100644 --- a/suds/mx/literal.py +++ b/suds/mx/literal.py @@ -145,7 +145,8 @@ def node(self, content): ns = content.type.namespace() if content.type.form_qualified: node = Element(content.tag, ns=ns) - node.addPrefix(ns[0], ns[1]) + if ns[0]: + node.addPrefix(ns[0], ns[1]) else: node = Element(content.tag) self.encode(node, content) diff --git a/suds/sax/element.py b/suds/sax/element.py index 9dec1f9..2ba9e73 100644 --- a/suds/sax/element.py +++ b/suds/sax/element.py @@ -130,6 +130,7 @@ def setPrefix(self, p, u=None): """ self.prefix = p if p is not None and u is not None: + self.expns = None self.addPrefix(p, u) return self diff --git a/suds/servicedefinition.py b/suds/servicedefinition.py index 81b5a0d..752c31b 100644 --- a/suds/servicedefinition.py +++ b/suds/servicedefinition.py @@ -184,7 +184,11 @@ def xlate(self, type): @rtype: str """ resolved = type.resolve() - name = resolved.name + if resolved.name is not None: + name = resolved.name + else: + name = '*' + if type.unbounded(): name += '[]' ns = resolved.namespace() diff --git a/suds/wsse.py b/suds/wsse.py index 2a697c1..84ea7f5 100644 --- a/suds/wsse.py +++ b/suds/wsse.py @@ -18,6 +18,7 @@ The I{wsse} module provides WS-Security. """ +import random from logging import getLogger from suds import * from suds.sudsobject import Object @@ -25,12 +26,6 @@ from suds.sax.date import UTC from datetime import datetime, timedelta -try: - from hashlib import md5 -except ImportError: - # Python 2.4 compatibility - from md5 import md5 - dsns = \ ('ds', @@ -136,13 +131,11 @@ def setnonce(self, text=None): @type text: str """ if text is None: - s = [] - s.append(self.username) - s.append(self.password) - s.append(Token.sysdate()) - m = md5() - m.update(':'.join(s)) - self.nonce = m.hexdigest() + # Random 16 bytes presented as a string + """TODO According to the standard, SOAP client must remember nonces, used in the last time, + to avoid duplicating random values. It is not implemented now. + """ + self.nonce = ''.join([chr(random.randint(0, 255)) for i in range(16)]) else: self.nonce = text @@ -209,4 +202,4 @@ def xml(self): expires.setText(str(UTC(self.expires))) root.append(created) root.append(expires) - return root \ No newline at end of file + return root