GetRoomLists成功但没有返回数据
我使用Exchange Web Services调用GetRoomLists,我们正在运行Exchange 2010.下面的代码正在通过控制台应用程序执行。调用成功,每个XML响应的“无错误”,但没有数据返回。当您尝试通过Outlook约会添加一个房间时,我们会列出几百个房间,因此不确定为何会发生这种情况。GetRoomLists成功但没有返回数据
我试过使用EWS DLL版本1.2和2.0,使用默认凭据或传入凭据。我注意到,在最初发布这个响应头文件表示我们使用的是Exchange 2012 SP2,因此我尝试更新我的代码以使用该ExchangeVersion枚举值,但没有更改结果。
我已成功地在此Exchange服务器上使用EWS来读取邮箱,但从未在房间之前。
C#
ExchangeService es = new ExchangeService(ExchangeVersion.Exchange2010);
es.TraceFlags = TraceFlags.EwsResponse | TraceFlags.EwsRequest;
es.TraceEnabled = true;
es.UseDefaultCredentials = true;
es.AutodiscoverUrl("[email protected]");
//this collection is empty after processing
EmailAddressCollection eac = es.GetRoomLists();
XML跟踪从Web服务请求/响应
<Trace Tag="EwsRequest" Tid="9" Time="2013-03-13 20:39:41Z" Version="14.03.0032.000">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010" />
</soap:Header>
<soap:Body>
<m:GetRoomLists />
</soap:Body>
</soap:Envelope>
</Trace>
<Trace Tag="EwsResponse" Tid="9" Time="2013-03-13 20:39:41Z" Version="14.03.0032.000">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="2" MajorBuildNumber="328" MinorBuildNumber="9" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetRoomListsResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ResponseCode>NoError</ResponseCode>
<m:RoomLists xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" />
</GetRoomListsResponse>
</s:Body>
</s:Envelope>
</Trace>
上GetRoomLists MSDN文档:http://msdn.microsoft.com/en-us/library/dd899416(v=exchg.140).aspx
嗯,我找到了原因/解决方案。令人困惑的是,GetRoomLists不会返回房间列表,而是返回房间列表或“房间列表”集合的列表。这些是包含房间列表的特殊类型的分配列表。
如此处所述,http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/4ff04c60-48c2-4a69-ab75-2383e73bfde2,您需要设置房间列表,或者需要查询AD并检查msExchRecipientDisplayType属性以查找房间。
此链接显示了如何编写LDAP查询返回房间为例:http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/e2d10953-a8f9-459c-8a0e-f10c2e568b26
代码我放在一起寻找房间:
private List<string> GetConfRooms(string filter)
{
List<string> sRooms = new List<string>();
DirectoryEntry deDomain = System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().GetDirectoryEntry();
DirectorySearcher dsRooms = new DirectorySearcher(deDomain);
dsRooms.Filter = string.Format("(&(&(&(mailNickname={0}*)(objectcategory=person)(objectclass=user)(msExchRecipientDisplayType=7))))", filter);
dsRooms.PropertiesToLoad.Add("sn");
dsRooms.PropertiesToLoad.Add("mail");
foreach (SearchResult sr in dsRooms.FindAll())
{
sRooms.Add(sr.Properties["mail"][0].ToString());
}
return sRooms;
}
它(LDAP解决方案)是否适合您? – Igal 2013-03-14 12:20:52
@ user301639 - 我的答案中的第二个链接的LDAP查询确实从AD返回了房间,所以它看起来像在工作。 – Peter 2013-03-14 12:39:42
我迷路了代码,有一些步骤顺序的死锁, string roRootDSE = dsDirectorySearcher.SearchRoot.Path; DirectoryEntry deDirectoryEntry = new DirectoryEntry(roRootDSE); DirectorySearcher dsDirectorySearcher = new DirectorySearcher(deDirectoryEntry); 你是如何解决它的? 谢谢! – Igal 2013-03-14 12:58:18
您是否尝试过使用不同的帐户?也许呼叫身份没有权限查看任何房间列表?在这种情况下,服务器只会返回空列表,如跟踪中所示。 http://msdn.microsoft.com/en-us/library/exchange/dd899416(v=exchg.140).aspx列出您的响应为典型的没有任何房间列表在服务器上。 – 2013-03-13 20:53:44
@RomanGruber - 刚刚读了一下房间列表实际是什么,我怎样才能得到一个像Outlook一样没有房间列表的交换房间列表? – Peter 2013-03-13 21:42:48