2013-03-29 115 views
0

我剛剛下載了PHP-EWS,按照README說明安裝,並啓動了一個腳本來測試它的功能。當我嘗試在瀏覽器中運行腳本時,我收到以下消息: enter image description herePHP-EWS沒有數據接收消息

當我提供登錄信息時,我知道該信息無效。看起來我連接到了我的Exchange服務器,但它不能識別我提供的憑據。

這裏是我使用

<?php 
function __autoload($className) 
{ 
    $className = str_replace('_','/', $className); 
    $sFileName = $className . '.php'; 

    if (file_exists($sFileName) && !class_exists($className)) 
    { 
     require_once $sFileName; 
    } 
    // If the above if fails, you're program will terminate, there is no way to catch this. 
} 

include("ExchangeWebServices.php"); 

$host = "https://myexchange/EWS/Services.wsdl"; 
$username = "[email protected]"; 
$password = "mypassword"; 

$ews = new ExchangeWebServices($host, $username, $password); 

$request = new EWSType_FindItemType(); 

$request->ItemShape = new EWSType_ItemResponseShapeType(); 
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES; 

$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW; 

$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType(); 
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType(); 
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX; 

// sort order 
$request->SortOrder = new EWSType_NonEmptyArrayOfFieldOrdersType(); 
$request->SortOrder->FieldOrder = array(); 
$order = new EWSType_FieldOrderType(); 
// sorts mails so that oldest appear first 
// more field uri definitions can be found from types.xsd (look for UnindexedFieldURIType) 
$order->FieldURI->FieldURI = 'item:DateTimeReceived'; 
$order->Order = 'Ascending'; 
$request->SortOrder->FieldOrder[] = $order; 

$response = $ews->FindItem($request); 
echo '<pre>'.print_r($response, true).'</pre>'; 

?> 

回答

1

嘗試通過測試您的訪問腳本:

直接擊中服務器網址:https:// YOUREXCHANGESERVER /EWS/Services.wsdl

你應提示輸入憑據。輸入憑據後,您將看到WSDL定義。如果它沒有爲您呈現一個類似於以下示例的WSDL定義,那麼請向您的管理員諮詢憑證或是否安裝了任何防火牆模塊。

例(部分緩解):

<wsdl:definitions targetNamespace="http://schemas.microsoft.com/exchange/services /2006/messages"><wsdl:types><xs:schema><xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/messages" schemaLocation="messages.xsd"/></xs:schema></wsdl:types>

一個偉大的工具,我在分析Web服務的使用方法是:SOAP-UI通過SmartBear