Пример #1
0
    def _process_request(self, service_client, service_binding,
                         service_endpoint, method, *args, **kwargs):
        message_id = uuid.uuid4().urn

        context = self._get_soap_context(service_client, service_binding,
                                         method, message_id, *args, **kwargs)

        channel = None
        try:
            channel = websocket.create_connection(
                service_endpoint,
                timeout=self.timeout,
                subprotocols=['soap'],
                header=['soap-content-type: text/xml'])
            channel.send(context.envelope)
            response = channel.recv()
            if isinstance(response, six.text_type):
                response = response.encode('utf-8')
            return context.process_reply(response)
        except (socket.error, websocket.WebSocketException) as e:
            traceback = sys.exc_info()[2]
            error = datacore_exceptions.DataCoreConnectionException(reason=e)
            six.reraise(datacore_exceptions.DataCoreConnectionException, error,
                        traceback)
        except suds.WebFault as e:
            traceback = sys.exc_info()[2]
            fault = datacore_exceptions.DataCoreFaultException(reason=e)
            six.reraise(datacore_exceptions.DataCoreFaultException, fault,
                        traceback)
        finally:
            if channel and channel.connected:
                try:
                    channel.close()
                except (socket.error, websocket.WebSocketException) as e:
                    LOG.debug(
                        "Closing a connection to "
                        "DataCore server failed. %s", e)
Пример #2
0
 def fail_with_datacore_fault(*args):
     raise datacore_exception.DataCoreFaultException(
         reason="General error.")