The Autodiscover service couldn't be located - EWS API AutodiscoverUrl 报错


使用EWS Managed API 进行邮件收取


提示为AutodiscoverUrl处异常, The Autodiscover service couldn't be located 。

在xp x86本地开发环境下代码没有问题,放到win2008x64上时报错,说明与程序运行环境有关。

查阅官方文档:Getting Started with the EWS Managed API 可得知,ssl可导致这个错误出现。

可根据官方文档添加以下代码:
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
// Hook up the cert callback.
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate(
Object obj,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors errors)
{
// Validate the certificate and return true or false as appropriate.
// Note that it not a good practice to always return true because not
// all certificates should be trusted.
};



另,一网友也碰到了此问题,并附有解决方法:http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/bdc45cd8-6385-4900-9e40-23814beb7639?Thread%3Abdc45cd8-6385-4900-9e40-23814beb7639=Microsoft.Forums.Data.Models.Discussion&ThreadViewModel%3Abdc45cd8-6385-4900-9e40-23814beb7639=Microsoft.Forums.CachedViewModels.ThreadViewModel


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM