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