单击网页上的图标会触发对PHP脚本的jQuery AJAX调用,该脚本使用SOAP将本地数据库同步到SugarCRM数据库。
通过在有问题的语句之前和之后发送自己的电子邮件,我可以看到SOAP连接成功,但随后的login()失败而没有抛出SoapFault或正常的异常。
从命令行开始,它可以正常工作。
提前感谢任何建议
更新:一些代码......
//来自网页的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();
}
});
//来自... / apps.net/synch_with_CRM.php的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( 'programmer@apps.net', '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( 'programmer@apps.net', '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( 'programmer@apps.net', 'soap fault', print_r( $fault, true ) );
}
catch( Exception $e ) { # there is no Exception thrown
mail( 'programmer@apps.net', 'exception', print_r( $e, true ) );
}
} # end get_connection
?>
答案 0 :(得分:0)
无论如何,您可以发布一些代码来突出问题?此外,您可能希望尝试通过REST与SOAP进行此操作,因为REST会更快。