2011-08-04 15 views
1

Webページのアイコンをクリックすると、SOAPを使用してローカルデータベースをSugarCRMデータベースと同期させるPHPスクリプトへのjQuery AJAX呼び出しがトリガーされます。jQuery AJAX呼び出しが失敗する(SugarCRM)

問題のある文の前後に電子メールを送信すると、SOAP接続が成功したことがわかりますが、それ以降のlogin()はSoapFaultまたは通常のExceptionをスローすることなく失敗します。

コマンドラインからは動作します。任意の提案を事前に

おかげ

UPDATE:いくつかのコード... Webページから

// 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 
?> 
+0

タイムアウトの問題ではありません - SOAP呼び出しが試行されるとすぐにスクリプトが終了します。 – marklark

答えて

0

とにかく問題を強調するコードを投稿できますか?また、RESTがはるかに高速になるため、RESTとSOAPを比較してみるとよいでしょう。

+0

このスクリプトはSugarCRM 5.2,5.5,6.1(いずれもクライアントが使用しています)で動作します.RESTは5.5+ – marklark

関連する問題