Exchange Web服务 – 从服务收到的响应不包含有效的XML

我正在尝试连接到Exchange 2010服务器上的交换Web服务(ews)。 这是我正在使用的代码:

using System; using System.Collections.Generic; using System.Text; using Microsoft.Exchange.WebServices.Data; namespace NDR_Processor { class Program { static void Main(string[] args) { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1); service.Credentials = new System.Net.NetworkCredential("redacted", "redacted", "redacted"); service.Url = new Uri("https://exchange.redacted.net/EWS/Exchange.asmx"); System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; FindItemsResults findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(1000)); foreach (Item item in findResults.Items) { Console.WriteLine(item.Subject); Console.WriteLine(item.Body); } } } } 

但是,在这样做时,我收到一条错误,指出“从服务收到的响应不包含有效的XML。”。 内部exception表示:{“根级别的数据无效。第1行,第1位。”}

我已经尝试在网络浏览器中点击https://exchange.redacted.net/EWS/Exchange.asmx ,它会提示我登录,然后我会看到一个有效的XML文档,据我所知。 所以我不知道为什么我的应用程序窒息。

有没有人对为什么会发生这种情况或如何解决它有任何想法?

谢谢Brad

 service.Url = new Uri("https://mail.tencent.com/EWS/Exchange.asmx"); 

详细信息在这里: c#以编程方式从Exchange服务器读取电子邮件

我遇到了与以下论坛post中描述的相同的问题: http : //social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/e54c217f-28ff-4626-8ce8-a1242081f4d1/

(基本上额外的字符被预先添加并附加到返回的xml,导致上面的错误)

如果有任何帮助 – 删除和重新创建EWS虚拟目录并没有缓解问题。

我相信也许我们的F5负载均衡器或某些中间设备在XML的开头或结尾插入额外的字符。

当我将代码更改为:service.Url = new Uri(“https:// 192.168.xx /EWS/Exchange.asmx”);

(基本上使用我们的交换服务器的内部IP地址)请求工作正常。 因此,交换之外的东西正在破坏XML。