George Sakkis avatar George Sakkis committed bfb93b7

Auto service generation for Exchange ill-formed WSDL.
Ported from

Comments (0)

Files changed (1)

+        self._ensure_service()
         for s in
         log.debug("WSDL at '%s' loaded:\n%s", url, self)
+    def _ensure_service(self):
+        """Trying to add service if no one definied explicitly. EWS workaround."""
+        if (
+            or not self.bindings
+            or len(self.bindings) > 1
+            or not self.bindings.keys()[0][0].startswith('Exchange')):
+            return
+        service = Element('service')
+        service.set('name', 'ExchangeServices')
+        port = Element('port', service)
+        port.set('name', 'ExchangeServicePort')
+        port.set('binding', self.bindings.keys()[0][0])
+        address = Element('address', port)
+        address.set('location', urljoin(self.url, 'exchange.asmx'))
+        port.append(address)
+        service.append(port)
+        service = Factory.create(service, self)
+        service.resolve(self)
+        self.children.append(service)
+        log.debug('Auto created service: %s', service)
     def mktns(self, root):
         """ Get/create the target namespace """
         tns = root.get('targetNamespace')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.