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