diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 263a96bdca4edbdb0542cb5ecddc9d9da1f1feb7..4ae8fb177540761a2f1c3474f8a50ce4701f066e 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1049,8 +1049,8 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
 
 if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('cancel'))
 {
-    $ws_host        = GETPOST('ws_host','alpha');
-    $ws_key         = GETPOST('ws_key','alpha');
+    $ws_url         = $object->thirdparty->webservices_url;
+    $ws_key         = $object->thirdparty->webservices_key;
     $ws_user        = GETPOST('ws_user','alpha');
     $ws_password    = GETPOST('ws_password','alpha');
     $ws_entity      = GETPOST('ws_entity','int');
@@ -1069,18 +1069,20 @@ if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('
     //Is sync supplier web services module activated? and everything filled?
     if (empty($conf->syncsupplierwebservices->enabled)) {
         setEventMessage($langs->trans("WarningModuleNotActive",$langs->transnoentities("Module2650Name")));
-    } else if ($mode != "init" && (empty($ws_host) || empty($ws_key) || empty($ws_user) || empty($ws_password) || empty($ws_thirdparty))) {
+    } else if (empty($ws_url) || empty($ws_key)) {
+        setEventMessage($langs->trans("ErrorWebServicesFieldsRequired"), 'errors');
+    } else if (empty($ws_user) || empty($ws_password) || empty($ws_thirdparty)) {
         setEventMessage($langs->trans("ErrorFieldsRequired"), 'errors');
     }
     else
     {
         //Create SOAP client and connect it to order
-        $soapclient_order = new nusoap_client($ws_host."/webservices/server_order.php");
+        $soapclient_order = new nusoap_client($ws_url."/webservices/server_order.php");
         $soapclient_order->soap_defencoding='UTF-8';
         $soapclient_order->decodeUTF8(false);
 
         //Create SOAP client and connect it to product/service
-        $soapclient_product = new nusoap_client($ws_host."/webservices/server_productorservice.php");
+        $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php");
         $soapclient_product->soap_defencoding='UTF-8';
         $soapclient_product->decodeUTF8(false);
 
@@ -1123,7 +1125,11 @@ if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('
         $ws_parameters = array('authentication'=>$ws_authentication, 'order' => $order);
         $result_order = $soapclient_order->call("createOrder", $ws_parameters, $ws_ns, '');
 
-        if ($result_order["result"]["result_code"] != "OK")
+        if (empty($result_order["result"]["result_code"])) //No result, check error str
+        {
+            setEventMessage($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", 'errors');
+        }
+        else if ($result_order["result"]["result_code"] != "OK") //Something went wrong
         {
             setEventMessage($langs->trans("SOAPError")." '".$result_order["result"]["result_code"]."' - '".$result_order["result"]["result_label"]."'", 'errors');
         }
@@ -1970,8 +1976,8 @@ elseif (! empty($object->id))
 	elseif ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && ! GETPOST('cancel'))
 	{
 		$mode        = GETPOST('mode', 'alpha');
-		$ws_host     = GETPOST('ws_host','alpha');
-		$ws_key      = GETPOST('ws_key','alpha');
+		$ws_url      = $object->thirdparty->webservices_url;
+		$ws_key      = $object->thirdparty->webservices_key;
 		$ws_user     = GETPOST('ws_user','alpha');
 		$ws_password = GETPOST('ws_password','alpha');
         
@@ -1988,7 +1994,11 @@ elseif (! empty($object->id))
         print_titre($langs->trans('CreateRemoteOrder'));
 
         //Is everything filled?
-        if ($mode != "init" && (empty($ws_host) || empty($ws_key) || empty($ws_user) || empty($ws_password))) {
+        if (empty($ws_url) || empty($ws_key)) {
+            setEventMessage($langs->trans("ErrorWebServicesFieldsRequired"), 'errors');
+            $mode = "init";
+            $error_occurred = true; //Don't allow to set the user/pass if thirdparty fields are not filled
+        } else if ($mode != "init" && (empty($ws_user) || empty($ws_password))) {
             setEventMessage($langs->trans("ErrorFieldsRequired"), 'errors'); 
             $mode = "init";
         }
@@ -2001,26 +2011,29 @@ elseif (! empty($object->id))
             print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
             print '<input type="hidden" name="action" value="webservice">';
             print '<input type="hidden" name="mode" value="check">';
-            $textinput_size = "50";
-
-            //Remote Host URL
-            print '<tr><td>'.$langs->trans("Host").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_host"></td></tr>';
-
-            //Remote Webservices key
-            print '<tr><td>'.$langs->trans("KeyForWebServicesAccess").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_key"></td></tr>';
-
-            //Remote User
-            print '<tr><td>'.$langs->trans("User").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_user"></td></tr>';
 
-            //Remote Password
-            print '<tr><td>'.$langs->trans("Password").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_password"></td></tr>';
-
-            //Submit and cancel buttons
-            print '<tr><td align="center" colspan="2">';
-            print '<input class="button" type="submit" id="ws_submit" name="ws_submit" value="'.$langs->trans("CreateRemoteOrder").'">';
-            print ' &nbsp; &nbsp; ';
-            print '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
-            print '</td></tr>';
+            if ($error_occurred)
+            {
+                print "<br>".$langs->trans("ErrorOccurredReviseAndRetry")."<br>";
+                print '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
+            }
+            else
+            {
+                $textinput_size = "50";
+                // Webservice url
+                print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td colspan="3">'.dol_print_url($ws_url).'</td></tr>';
+                //Remote User
+                print '<tr><td>'.$langs->trans("User").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_user"></td></tr>';
+                //Remote Password
+                print '<tr><td>'.$langs->trans("Password").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_password"></td></tr>';
+                //Submit button
+                print '<tr><td align="center" colspan="2">';
+                print '<input class="button" type="submit" id="ws_submit" name="ws_submit" value="'.$langs->trans("CreateRemoteOrder").'">';
+                print ' &nbsp; &nbsp; ';
+                //Cancel button
+                print '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
+                print '</td></tr>';
+            }
 
             //End table/form
             print '</form>';
@@ -2032,14 +2045,8 @@ elseif (! empty($object->id))
             $ws_thirdparty = '';
             $error_occurred = false;
 
-            //Check if has transport, without any the soap client will give error
-            if (strpos($ws_host, "http") === false)
-            {
-                $ws_host = "http://".$ws_host;
-            }
-
             //Create SOAP client and connect it to user
-            $soapclient_user = new nusoap_client($ws_host."/webservices/server_user.php");
+            $soapclient_user = new nusoap_client($ws_url."/webservices/server_user.php");
             $soapclient_user->soap_defencoding='UTF-8';
             $soapclient_user->decodeUTF8(false);
 
@@ -2062,7 +2069,7 @@ elseif (! empty($object->id))
                 else
                 {
                     //Create SOAP client and connect it to product/service
-                    $soapclient_product = new nusoap_client($ws_host."/webservices/server_productorservice.php");
+                    $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php");
                     $soapclient_product->soap_defencoding='UTF-8';
                     $soapclient_product->decodeUTF8(false);
 
@@ -2086,7 +2093,11 @@ elseif (! empty($object->id))
 
                         // Check the result code
                         $status_code = $result_product["result"]["result_code"];
-                        if ($status_code != "OK")
+                        if (empty($status_code)) //No result, check error str
+                        {
+                            setEventMessage($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", 'errors');
+                        }
+                        else if ($status_code != "OK") //Something went wrong
                         {
                             if ($status_code == "NOT_FOUND")
                             {
@@ -2135,6 +2146,11 @@ elseif (! empty($object->id))
                 setEventMessage($langs->trans("RemoteUserNotPermission"), 'errors');
                 $error_occurred = true;
             }
+            elseif ($user_status_code == "BAD_CREDENTIALS")
+            {
+                setEventMessage($langs->trans("RemoteUserBadCredentials"), 'errors');
+                $error_occurred = true;
+            }
             else
             {
                 setEventMessage($langs->trans("ResponseNonOK")." '".$user_status_code."'", 'errors');
@@ -2146,15 +2162,13 @@ elseif (! empty($object->id))
             print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
             print '<input type="hidden" name="action" value="webservice">';
             print '<input type="hidden" name="mode" value="send">';
-            print '<input type="hidden" name="ws_host" value="'.$ws_host.'">';
-            print '<input type="hidden" name="ws_key" value="'.$ws_key.'">';
             print '<input type="hidden" name="ws_user" value="'.$ws_user.'">';
             print '<input type="hidden" name="ws_password" value="'.$ws_password.'">';
             print '<input type="hidden" name="ws_entity" value="'.$ws_entity.'">';
             print '<input type="hidden" name="ws_thirdparty" value="'.$ws_thirdparty.'">';
             if ($error_occurred)
             {
-                print "<br>".$langs->trans("ErrorOccurredReviseAndRetry")."<br>"; //TODO: Translate
+                print "<br>".$langs->trans("ErrorOccurredReviseAndRetry")."<br>";
             }
             else
             {
diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
index c2e10543b7ae1a03041d62e2cd47f6d985ef2fb3..552563db677f37c16909ac9abe757edd3668b064 100644
--- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
+++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
@@ -1110,3 +1110,6 @@ DELETE FROM llx_menu WHERE module = 'boutique';
 -- Add option always editable on extrafield
 ALTER TABLE llx_extrafields ADD alwayseditable INTEGER DEFAULT 0 AFTER pos;
 
+-- add supplier webservice fields
+ALTER TABLE llx_societe ADD webservices_url varchar(255) DEFAULT NULL;
+ALTER TABLE llx_societe ADD webservices_key varchar(128) DEFAULT NULL;
diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql
index bfe69b0d5f85727196b0e1b01509a6f63b24d250..b9327ba521c659b4eb58c21c3645ed5002ea4d73 100644
--- a/htdocs/install/mysql/tables/llx_societe.sql
+++ b/htdocs/install/mysql/tables/llx_societe.sql
@@ -92,4 +92,6 @@ create table llx_societe
   logo                     varchar(255),
   canvas				   varchar(32),			                        -- type of canvas if used (null by default)
   import_key               varchar(14)                          		-- import key
+  webservices_url          varchar(255),                            -- supplier webservice url
+  webservices_key          varchar(128),                            -- supplier webservice key
 )ENGINE=innodb;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 6d80189c7beaedd1b2354e781ab1c9e6b5f90742..79d24a8d917df710a756ff475cc11157d553eeab 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -334,6 +334,18 @@ class Societe extends CommonObject
      */
     var $import_key;
 
+    /**
+     * Supplier WebServices URL
+     * @var string
+     */
+    var $webservices_url;
+
+    /**
+     * Supplier WebServices Key
+     * @var string
+     */
+    var $webservices_key;
+
     var $logo;
     var $logo_small;
     var $logo_mini;
@@ -715,6 +727,10 @@ class Societe extends CommonObject
         	$supplier=true;
         }
 
+        //Web services
+        $this->webservices_url = $this->webservices_url?clean_url($this->webservices_url,0):'';
+        $this->webservices_key = trim($this->webservices_key);
+
         $this->db->begin();
 
         // Check name is required and codes are ok or unique.
@@ -795,6 +811,9 @@ class Societe extends CommonObject
             $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->default_lang."'":"null");
             $sql .= ",logo = ".(! empty($this->logo)?"'".$this->logo."'":"null");
 
+            $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null");
+            $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null");
+
             if ($customer)
             {
                 $sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null");
@@ -951,6 +970,7 @@ class Societe extends CommonObject
         $sql .= ', s.fk_typent as typent_id';
         $sql .= ', s.fk_effectif as effectif_id';
         $sql .= ', s.fk_forme_juridique as forme_juridique_code';
+        $sql .= ', s.webservices_url, s.webservices_key';
         $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
         $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
         $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
@@ -1086,6 +1106,9 @@ class Societe extends CommonObject
                 $this->default_lang = $obj->default_lang;
                 $this->logo = $obj->logo;
 
+                $this->webservices_url = $obj->webservices_url;
+                $this->webservices_key = $obj->webservices_key;
+
                 $this->outstanding_limit		= $obj->outstanding_limit;
 
                 // multiprix
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index a0b9bda1c8e0ef6368b41e0eb5e5c1a358c311df..8117de5f09b78f44e838828fc6fa575eaf9a9a60 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -119,7 +119,7 @@ if (empty($reshook))
     	$res=$object->setValueFrom('localtax2_value', $value);
     }
 
-    // Add new third party
+    // Add new or update third party
     if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode'))
     && ($action == 'add' || $action == 'update') && $user->rights->societe->creer)
     {
@@ -189,6 +189,10 @@ if (empty($reshook))
         $object->commercial_id         = GETPOST('commercial_id', 'int');
         $object->default_lang          = GETPOST('default_lang');
 
+        // Webservices url/key
+        $object->webservices_url       = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
+        $object->webservices_key       = GETPOST('webservices_key', 'san_alpha');
+
         // Fill array 'array_options' with data from add form
         $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
 
@@ -217,6 +221,18 @@ if (empty($reshook))
                 $error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
                 $action = ($action=='add'?'create':'edit');
             }
+            if (! empty($object->webservices_url)) {
+                //Check if has transport, without any the soap client will give error
+                if (strpos($object->webservices_url, "http") === false)
+                {
+                    $object->webservices_url = "http://".$object->webservices_url;
+                }
+                if (! isValidUrl($object->webservices_url)) {
+                    $langs->load("errors");
+                    $error++; $errors[] = $langs->trans("ErrorBadUrl",$object->webservices_url);
+                    $action = ($action=='add'?'create':'edit');
+                }
+            }
 
             // We set country_id, country_code and country for the selected country
             $object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id;
@@ -1179,6 +1195,10 @@ else
                 $object->tva_intra				= GETPOST('tva_intra', 'alpha');
                 $object->status					= GETPOST('status', 'int');
 
+                // Webservices url/key
+                $object->webservices_url        = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
+                $object->webservices_key        = GETPOST('webservices_key', 'san_alpha');
+
                 //Local Taxes
                 $object->localtax1_assuj		= GETPOST('localtax1assuj_value');
                 $object->localtax2_assuj		= GETPOST('localtax2assuj_value');
@@ -1558,6 +1578,14 @@ else
             	print $object->showOptionals($extrafields,'edit');
             }
 
+            // Webservices url/key
+            if (!empty($conf->syncsupplierwebservices->enabled)) {
+                print '<tr><td><label for="webservices_url">'.$langs->trans('WebServiceURL').'</label></td>';
+                print '<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.'"></td>';
+                print '<td><label for="webservices_key">'.$langs->trans('WebServiceKey').'</label></td>';
+                print '<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.'"></td></tr>';
+            }
+
             // Logo
             print '<tr class="hideonsmartphone">';
             print '<td><label for="photoinput">'.$langs->trans("Logo").'</label></td>';
@@ -2014,6 +2042,12 @@ else
             print "</tr>\n";
         }
 
+        // Webservices url/key
+        if (!empty($conf->syncsupplierwebservices->enabled)) {
+            print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td>'.dol_print_url($object->webservices_url).'</td>';
+            print '<td class="nowrap">'.$langs->trans('WebServiceKey').'</td><td>'.$object->webservices_key.'</td></tr>';
+        }
+
         print '</table>';
 
         dol_fiche_end();