單擊網頁上的圖標會觸發對使用SOAP將本地數據庫同步到SugarCRM數據庫的PHP腳本的jQuery AJAX調用。jQuery對腳本的AJAX調用失敗(SugarCRM)
通過在有問題的語句前後發送自己的電子郵件,我可以看到SOAP連接成功,但隨後的登錄()失敗而沒有拋出SoapFault或正常的異常。
從命令行,它的工作原理。
在此先感謝您的任何建議
UPDATE:一些代碼...
// javascript中的網頁
url = 'http://apps.net/synch_with_CRM.php?clientGuid=141516'
// Submit via Ajax if there aren't any errors
jQuery.ajax({
url: url,
success: function(){
jQuery("#dialog-message").dialog({
buttons: {
Ok: function() {
jQuery(this).dialog('close'); /* Closes popup */
}
}
})
jQuery("#loading_" + crm).hide();
jQuery("#icon_sync_" + crm).show();
}
});
從// PHP代碼.../apps.net /synch_with_CRM.php
<?php
if ($_REQUEST['clientGuid']) { # get the URL parameter
$client_guid = $_REQUEST['clientGuid'];
}
else if ($argv) { # get the command-line parameter
$client_guid = $argv[$argc - 1]; # clientGuid must be last
}
$client = new Client($client_guid);
$client_id = $client->GetId();
# connection information is the same for AJAX or command-line
$connection_info = getConnectionInfo($client_id, 'SugarCRM');
$API_soap_client = get_connection($connection_info);
if (!$API_soap_client) {
exit("SOAP client connection failed\n");
}
# do other stuff here...
# SNIP!
function get_connection($connection_info) {
global $soap_session_id;
try {
$options = array('location' => $connection_info['url'],
'uri' => $connection_info['uri'],
'trace' => 1);
$auth_array = array('user_name' => $connection_info['username'],
'password' => md5($connection_info['password']));
$API_soap_client = new soapclient(NULL, $options);
# I get the following email whether by AJAX or command-line
mail('[email protected]', 'soapclient', print_r($API_soap_client, true));
$soap_session = $API_soap_client->login($auth_array);
# I only get this email if the script is run from the command-line
mail('[email protected]', 'soap id', print_r($soap_session, true));
$soap_session_id = $soap_session->id;
if ($soap_session_id != -1) return $API_soap_client;
else return false;
}
catch(SoapFault $fault) { # there is no SoapFault thrown
mail('[email protected]', 'soap fault', print_r($fault, true));
}
catch(Exception $e) { # there is no Exception thrown
mail('[email protected]', 'exception', print_r($e, true));
}
} # end get_connection
?>
這不是一個超時問題 - 只要嘗試SOAP調用,腳本就會結束。 – marklark