/**
  * Check that the webservice works.
  * Tests endpoint, authentication and actual response
  *
  * @param string $webservice The webservice URL
  * @param string[] $ws_auth The webservice authentication array
  */
 private function test_webservice($webservice = '', $ws_auth = array())
 {
     if (empty($webservice) && !empty($this->dolibarr_ws_endpoint)) {
         $webservice = $this->dolibarr_ws_endpoint;
     }
     if (empty($webservice)) {
         // We don't want to check unconfigured plugin
         return;
     }
     if (empty($ws_auth)) {
         $ws_auth = array('dolibarrkey' => $this->dolibarr_key, 'sourceapplication' => $this->sourceapplication, 'login' => $this->dolibarr_login, 'password' => $this->dolibarr_password, 'entity' => $this->dolibarr_entity);
     }
     // Check that the server is available
     try {
         $soap_client = new SoapClient($webservice . Doliwoo_Dolibarr::OTHER_ENDPOINT . Doliwoo_Dolibarr::WSDL_MODE);
     } catch (SoapFault $exc) {
         $this->errors[] = __('The webservice is not available. Please check the URL.', 'doliwoo');
         $this->display_errors();
         // No point in doing the next test
         return;
     }
     try {
         $response = $soap_client->getVersions($ws_auth);
     } catch (SoapFault $exc) {
         $this->errors[] = 'Webservice error:' . $exc->getMessage();
         $this->display_errors();
         // No point in doing the next test
         return;
     }
     if ('OK' == $response['result']->result_code) {
         $this->dolibarr_version = explode('.', $response['dolibarr']);
     } else {
         $this->errors[] = 'Webservice error:' . $response['result']->result_label;
         $this->display_errors();
     }
 }