Esempio n. 1
0
    def __init__(self, options, log_file_name=WSFC.WSF_DEFAULT_LOG_FILE_NAME):
        self.service_client = None
        self.options = {}

        # Copy user options into options dictionary of WSClient.
        self.options = options.copy()

        # Get the log directory and log level from user options. 
        # If user has not given these options defaults are used.
        if self.options.has_key(WSFC.WSF_CONF_LOG_DIR):
            log_dir = self.options[WSFC.WSF_CONF_LOG_DIR]
        else:
            log_dir = self.get_default_log_dir()

        if self.options.has_key(WSFC.WSF_CONF_LOG_LEVEL):
            log_level = int(self.options[WSFC.WSF_CONF_LOG_LEVEL])
        else:
            log_level = 4 

        # Create the log file path using user options.
        log_file = os.path.join(log_dir, log_file_name)

        # Create a Logger object to  use in WSClient.
        self.logger = Logger(log_file, log_level)

        # Create the axis2 environment.
        self.env = WSFC.axutil_env_create_all(log_file, log_level)
        if self.env is None:
            self.logger.log_critical("Failed to create WSFC environment....")
            return
        
        if self.options.has_key(WSFC.WSF_CONF_WSFC_HOME):
            wsfc_home = self.options[WSFC.WSF_CONF_WSFC_HOME]
        else: 
            wsfc_home = WSFC.WSF_DEFAULT_WSF_HOME
        
        # Create the service client.
        self.service_client = WSFC.axis2_svc_client_create(self.env, wsfc_home)
        if self.service_client is None:
            WSFC.axis2_log_critical(self.env, "[wsf-python] Failed to create service client.")
            return
        
        
        # Set service client options.
        svc_client_options = WSFC.axis2_svc_client_get_options( \
                self.service_client, self.env)
        if svc_client_options is None:
            svc_client_options = WSFC.axis2_options_create(self.env)
            WSFC.axis2_svc_client_set_options(self.service_client, \
                            self.env, svc_client_options)
        
        self.set_client_options(svc_client_options)
        
        pass