2016-04-29 27 views
0

情報のphp-EWS:致命的なエラー:キャッチされないにSoapFault例外:[クライアント]クラスのEWS_Exception "

私は今年のように、このコードを実行されており、すべてが昨日まで正常に動作しました。以下のエラーメッセージを参照してください。このコードは、受信トレイ内の未読メールの数だけを取得します。数が増える中で、コードを実行しているクライアントで音が鳴ります。私のExchangeサーバーはExchange Server 2013 CU12を実行していますが、常にExchangeWebServices :: VERSION_2010(コードを参照)で動作しています。

エラーメッセージ

致命的なエラー:キャッチされないにSoapFault例外:/var/www/html/php-ews/NTLMSoapClient.php:87スタックトレースでは見られない[クライアント]クラスのEWS_Exception ':#0 NTLMSoapClient :: __ doRequest()#1 [内部関数]:NTLMSoapClient-> __doRequest( 'https://mail.se ...'、/var/www/html/php-ews/NTLMSoapClient.php(87) http://schemas .... '、1、0)#2 /var/www/html/php-ews/ExchangeWebServices.php(552):SoapClient - > __ call(' FindItem '、Array)#3/var/www/html// Exchange_WebServices-> FindItem(Object(EWSType_FindItemType))#5/Exchange_WebServices-> FindItem(オブジェクト(EWSType_FindItemType))#4 /var/www/html/mail.php(104):ExchangeWebServices-> FindItem {main}/var/www/html/php-ewにスローされましたS/87

私のコードは1に基づいている行にNTLMSoapClient.phpはこちらをご覧ください:http://litphp.info/want_to_print_unread_mail_body_and_subject_using_ews_from_exchange_server_in_php

私のコード

function __autoload($class_name) 
{ 
    // Start from the base path and determine the location from the class name, 
    $base_path = 'php-ews'; 
    $include_file = $base_path . '/' . str_replace('_', '/', $class_name) . '.php'; 

    return (file_exists($include_file) ? require_once $include_file : false); 
} 

$ews = new ExchangeWebServices("mail.server.path.com", $mailuser, $mailpass, ExchangeWebServices::VERSION_2010); 

$request = new EWSType_FindItemType(); 
$itemProperties = new EWSType_ItemResponseShapeType(); 
$itemProperties->BaseShape = EWSType_DefaultShapeNamesType::ID_ONLY; 
$itemProperties->BodyType = EWSType_BodyTypeResponseType::BEST; 
$request->ItemShape = $itemProperties; 

$fieldType = new EWSType_PathToUnindexedFieldType(); 
$fieldType->FieldURI = 'message:IsRead'; 

$constant = new EWSType_FieldURIOrConstantType(); 
$constant->Constant = new EWSType_ConstantValueType(); 
$constant->Constant->Value = "0"; 

$IsEqTo = new EWSType_IsEqualToType(); 
$IsEqTo->FieldURIOrConstant = $constant; 
$IsEqTo->Path = $fieldType; 

$request->Restriction = new EWSType_RestrictionType(); 
$request->Restriction->IsEqualTo = new EWSType_IsEqualToType(); 
$request->Restriction->IsEqualTo->FieldURI = $fieldType; 
$request->Restriction->IsEqualTo->FieldURIOrConstant = $constant; 

$request->IndexedPageItemView = new EWSType_IndexedPageViewType(); 
$request->IndexedPageItemView->BasePoint = 'Beginning'; 
$request->IndexedPageItemView->Offset = 0; 

$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType(); 
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType(); 
$request->ParentFolderIds->DistinguishedFolderId->Mailbox = new StdClass; 
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = '[email protected]'; 
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX; 

$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW; 

$result = new EWSType_FindItemResponseMessageType(); 
$result = $ews->FindItem($request); 

if ($result->ResponseMessages->FindItemResponseMessage->ResponseCode == 'NoError' && $result->ResponseMessages->FindItemResponseMessage->ResponseClass == 'Success'){ 

    // Need this variable to check for the new value. 
    $count_new = $result->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView; 

    // Play sound if value has increased. 
    if($_SESSION['count_previous'] < $count_new) { 
     echo '<script type="text/javascript">play_sound();</script>'; 
    } 

    // Saving the value for later usage. 
    $count = $result->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView; 

    // Saving the current count to a session. Need it to compair with the new value ($count_new). 
    $_SESSION['count_previous'] = $count; 

    if($count > 0) { 
     echo '<script type="text/javascript">document.body.style.backgroundColor = "#fc2828";</script>'; 
     echo "<h1>" . $count . "</h1><br>"; 
     echo '<img src="img/mail.png" height="165px">'; 
    } else { 
     echo '<h1 class="paddingH12 test">No mail</h1>'; 
    } 

} 

私はそれがコードが停止していることも考えていたしばらくしてサーバーが2013 CU12であるため、「VERSION_2010」のように動作します。私は以下の解決策を試しましたが、うまくいかなかった:https://github.com/jamesiarmes/php-ews/issues/195

誰もがこの問題を解決する方法を知っていますか?コードは1年ほど働いていたので少し不満ですが、今はそうではありません。サーバー側で何も変更されていません。

ありがとうございます。

+2

私はまた、60秒(それ以外の音は動作しません)の後にページを更新しています彼の図書館から離れていくと、古くて、維持されていません。私は私のフォークをhttp://github.com/garethp/php-ewsで試してみることをお勧めします。簡単な例では未読メールを簡単に手に入れることができます。 –

+0

Aha、ありがとう。確かめます。 – Treps

答えて

0

この投稿は申し訳ありません。それは今再び働いている。私はその問題が何だったのか分からない。おそらく、Exchangeサーバーまたはネットワークの負荷が高いでしょう。未読メールのみを取得する場合は、このコードを自由に使用してください。サウンドの

<meta http-equiv="refresh" content="60"> 

のJavaScript(ヘッダーに表示)::私は非常にお勧めし

<script type="text/javascript"> 
    function play_sound() { 
     var audioElement = document.createElement('audio'); 
     audioElement.setAttribute('src', '/sound/mail.mp3'); 
     audioElement.setAttribute('autoplay', 'autoplay'); 
     audioElement.load(); 
     audioElement.play(); 
    } 
</script> 
+0

コードはExchange 2013、2013 CU11および2013 CU12で動作しています。 2010年といっても;) – Treps

関連する問題