0

我刚刚下载了 PHP-EWS,按照 README 说明安装,然后编写了一个脚本来测试它的功能。当我尝试在浏览器中运行脚本时,我收到以下消息: 在此处输入图像描述

当我提供我知道无效的登录名时,我收到相同的消息。我似乎正在连接到我的 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 = "myusername@mydomain.com";
$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>';

?>
4

1 回答 1

2

尝试通过以下方式测试您的访问权限:

直接点击服务器 url: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 服务时使用的一个很棒的工具是:SmartBear的 SOAP-UI

于 2013-08-29T22:40:51.197 回答