我面臨同樣的問題,找到這樣的事 - 並試圖大多一切(除了從editig了Java API EWS本身)在我的Spring Web應用程序與Exchange 2007 SP1,以與StartTimeZone工作約會 - 沒有成功。
,我發現這樣的評語: 不幸的是,Exchange 2007 SP1中不支持EWS的StartTimeZone財產。如果你想使用該屬性,您必須使用Exchange 2010 我應該去,找少「flacky的」 Java交換框架。
我不是高興,因爲我聽說有在.NET宇宙中沒有這樣的問題,我決定去與以下解決方案:
我建立了一個自託管南希服務器。
看到Nancy Documentation
並寫了一個簡單NancyModule:通過傳遞我的約會數據經由RestTemplate JSON對象
namespace WebServiceNancy
{
public class APIModul : NancyModule
{
public APIModul() : base("/")
{
Post["/saveFooApp"] = _ =>
{
var jsonApp = this.Bind<AppData>();
string ewsURL = "https://saveFooApp/ews/exchange.asmx";
System.Uri ewsUri = new System.Uri(ewsURL);
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = ewsUri;
service.Credentials = new WebCredentials(jsonApp.Username, jsonApp.Password);
Appointment app = new Appointment(service);
app.Subject = jsonApp.Title;
app.Start = jsonApp.Start;
app.End = jsonApp.End;
app.Save(WellKnownFolderName.Calendar);
return Response.AsText("OK").WithStatusCode(HttpStatusCode.OK);
};
}
}
public class AppData
{
public string Title { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
}
現在我可以從我的春節控制器稱之爲WS:
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startDate = formatter.format(fooMeeting.getMeetingStart());
String endDate = formatter.format(fooMeeting.getMeetingEnd());
JSONObject obj = new JSONObject();
obj.put("title", fooMeeting.getTitle());
obj.put("start", startDate);
obj.put("end", endDate);
obj.put("username", fooUser.getUsername());
obj.put("password", fooUser.getPassword());
RestTemplate rt = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
JSONSerializer jsonSer = new JSONSerializer();
HttpEntity<String> entity = new HttpEntity<String>(jsonSer.serialize(obj), headers);
ResponseEntity<String> response = rt.exchange("http://localhost:8282/saveFooApp", HttpMethod.POST, entity, String.class);
System.out.println(response.getStatusCode());
OFC u需要來決定,如果你想從一臺服務器傳遞憑據時他人使用某種形式的密碼加密 - 你如何實現你的錯誤處理。
我想你的答案是在[thread] [1]。 [1]:http://stackoverflow.com/questions/4133625/problem-retrieving-appointment-starttimezone-through-ews-managed-api-on-exchange – ahmeric
也許不是你要找的意見,但你有沒有看過使用Exchange 2007公開的Web服務?我發現Java託管API非常片狀。 http://msdn.microsoft.com/en-us/library/bb421489(v=exchg.80).aspx – cduggan