【问题标题】:Exchange WebService EWS FindAppointmens 501: Not ImplementedExchange WebService EWS FindAppointmens 501:未实施
【发布时间】:2014-03-25 05:46:01
【问题描述】:

我们有一个 Exchange Server 2010 SP2 在本地运行。 我正在使用 EWS 托管 API(我已经尝试过 API/DLL 版本 1.2 和 2.1)来连接它。我能够检索日历、EWS 服务名称和版本信息,但在“var appointments = calendar.FindAppointments(calenderView);”线上我得到一个 501 - Not Implement 异常(见图)。

我已经在网上搜索过,但找不到有关此错误的任何信息,也没有在 MSDN 上找到信息。 下面是我使用的代码:

主要方法:

        private void Main_Load(object sender, EventArgs e)
        {
            ConnectWithExchange();
            GetCalendarItems();
        }

实例化

        /// <summary>
        /// http://msdn.microsoft.com/en-us/library/office/ff597939(v=exchg.80).aspx
        /// </summary>
        private void ConnectWithExchange()
        {
            // 01. Instantiate ExchangeService
            _exchange = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

            // 02. Connect with credentials
            _exchange.UseDefaultCredentials = true;
            // or pass through credentials of a service user:
            // _exchange.Credentials = new WebCredentials("user@name", "password", "domain");

            // 03. Set correct endpoint
            // http://msdn.microsoft.com/en-us/library/office/gg274410(v=exchg.80).aspx
            // _exchange.Url = new Uri("https://outlook.kdg.be/EWS/Exchange.asmx");
            // or use autodiscover
            _exchange.AutodiscoverUrl("name@domain.com"); // works ok

            // 04. Display version and info
            UxExchangeVersion.Text = _exchange.Url.ToString(); // works ok           
        }

检索日历项目

        /// <summary>
        /// http://msdn.microsoft.com/en-us/library/office/dn439786(v=exchg.80).aspx
        /// </summary>
        private void GetCalendarItems()
        {
            // 01. Init calendar folder object with the folder ID
            CalendarFolder calendar = CalendarFolder.Bind(_exchange, WellKnownFolderName.Calendar, new PropertySet(FolderSchema.DisplayName));

            // 02. Set start and end time and number of appointments to retrieve
            CalendarView calenderView = new CalendarView(DateTime.Now, DateTime.Now.AddDays(7), 150);

            // 03. Limit the properties returned
            calenderView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);

            // 04. Fetch the appointments
            var appointments = calendar.FindAppointments(calenderView);
            // var appointments = _exchange.FindAppointments(calendar.Id, new CalendarView(DateTime.Now, DateTime.Now.AddDays(7))); // **failure point**

            // 05. Display appiontments in list
            // 05A. Fetch calender name
            uxCalenderName.Text = calendar.DisplayName + " (" + calendar.Id.Mailbox + ")";
            // 05B. Fill list            
            uxAppointments.Items.Clear();
            foreach (var appointment in appointments)
            {
                var appointmentString = new StringBuilder();

                appointmentString.Append("Subject: " + appointment.Subject.ToString() + " ");
                appointmentString.Append("Start: " + appointment.Start.ToString() + " ");
                appointmentString.Append("End: " + appointment.End.ToString());

                uxAppointments.Items.Add(appointmentString.ToString());
            }
        }

【问题讨论】:

    标签: c# exchange-server exchangewebservices


    【解决方案1】:

    我运行了 GetCalendarItems(),它对我来说很好用。我注意到您在 _exchange.AutodiscoverUrl 中没有 URL 重定向回调。我很惊讶您可以在没有重定向的情况下获取 URL。

    internal static bool RedirectionUrlValidationCallback(string redirectionUrl)
    {
        // The default for the validation callback is to reject the URL.
        bool result = false;
    
        Uri redirectionUri = new Uri(redirectionUrl);
    
        // Validate the contents of the redirection URL. In this simple validation
        // callback, the redirection URL is considered valid if it is using HTTPS
        // to encrypt the authentication credentials. 
        if (redirectionUri.Scheme == "https")
        {
            result = true;
        }
    
        return result;
    }
    

    你能告诉我你的目标服务器吗?您的目标是哪个版本的 Exchange?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-07
    • 1970-01-01
    • 2014-09-28
    • 2012-02-22
    • 1970-01-01
    相关资源
    最近更新 更多