|
14 | 14 | import six |
15 | 15 | from lxml import etree |
16 | 16 |
|
| 17 | +from zeep import ns |
17 | 18 | from zeep.exceptions import IncompleteMessage |
18 | 19 | from zeep.loader import absolute_location, is_relative_path, load_external |
19 | 20 | from zeep.settings import Settings |
|
23 | 24 |
|
24 | 25 |
|
25 | 26 | NSMAP = { |
26 | | - 'wsdl': 'http://schemas.xmlsoap.org/wsdl/', |
| 27 | + 'wsdl': ns.WSDL, |
| 28 | + 'wsp': ns.WSP, |
| 29 | + 'sp': ns.SP, |
| 30 | + 'wsu': ns.WSU, |
27 | 31 | } |
28 | 32 |
|
29 | 33 | logger = logging.getLogger(__name__) |
@@ -422,6 +426,25 @@ def parse_binding(self, doc): |
422 | 426 | logger.debug("Ignoring binding: %s", exc) |
423 | 427 | continue |
424 | 428 |
|
| 429 | + # Begin heuristics for signed parts... |
| 430 | + binding_policy = binding.name.localname + '_policy' |
| 431 | + signed_parts = doc.xpath('wsp:Policy[@wsu:Id="{}"]//sp:SignedParts'.format(binding_policy), |
| 432 | + namespaces=NSMAP) |
| 433 | + for sign in signed_parts: |
| 434 | + if len(sign.getchildren()) == 0: |
| 435 | + # No children, we should sign everything |
| 436 | + binding.signatures['body'] = True |
| 437 | + binding.signatures['everything'] = True |
| 438 | + break |
| 439 | + |
| 440 | + for child in sign.iterchildren(): |
| 441 | + if len(child.items()) > 0: |
| 442 | + # Header ... |
| 443 | + part = {attr: value for attr, value in child.items()} |
| 444 | + binding.signatures['header'].append(part) |
| 445 | + elif child.tag.split('}')[-1].lower() == 'body': |
| 446 | + # Body ... |
| 447 | + binding.signatures['body'] = True |
425 | 448 | logger.debug("Adding binding: %s", binding.name.text) |
426 | 449 | result[binding.name.text] = binding |
427 | 450 | break |
|
0 commit comments