1

我目前正在开发 Windows Azure 服务,我必须实现从 Exchange 服务器导入一些项目。当我在本地模拟器上测试它时一切正常,我可以导入项目,但部署在云上它停止工作。

这是我得到的例外:

异常类型:ServiceResponseException 异常消息:发生内部服务器错误。操作失败。

我使用的代码:

service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new NetworkCredential(userName, password, domain);
service.Url = new Uri(serverUrl);

itemPropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
itemPropertySet.RequestedBodyType = BodyType.Text;

CalendarView calendarView = new CalendarView(fromDate, toDate);
List<ExchangeTask> tasks = new List<ExchangeTask>();
try
{
    FindItemsResults<Appointment> appointments = service.FindAppointments(WellKnownFolderName.Calendar, calendarView);

    if (appointments.TotalCount > 0)
    {
        service.LoadPropertiesForItems(appointments, itemPropertySet);
    }
    foreach (Appointment app in appointments)
    {
        tasks.Add(new ExchangeTask() { Name = app.Subject, Description = app.Body, DeadLine = app.End.ToString() });
    }
    return tasks;
}
catch (Exception ex)
{
    throw ex;
}

编辑1: 这不是防火墙问题,因为如果我输入的用户名或密码不正确,则会引发未经授权的异常,因此它会连接到服务器。

4

2 回答 2

1

经过3天的痛苦,我解决了这个问题。问题是我没有在类的构造函数中指定时区ExchangeService。我的构造函数现在看起来像这样:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));

于 2013-04-05T11:29:57.527 回答
0

您应该检查 Windows Azure 上 VM 的防火墙策略

于 2013-04-03T10:53:31.497 回答