I faced the same problem - and tried mostly everything (besides from editig the java ews api itself) to make Appointments with StartTimeZone work with Exchange 2007 SP1 in my Spring Web Application - without success.
I found comments like:
Unfortunately, Exchange 2007 SP1 does not support the StartTimeZone property of EWS. If you want to use that property, you must use Exchange 2010.
That i should go, look for less "flacky" Java Exchange Framework.
I wasnt pleased and as i heard there is no such problem in the .NET universe i decided to go with the following solution:
I set up a self-hosted Nancy Server.
see the Nancy Documentation
And wrote a simple NancyModule:
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; }
}
}
Now i can call this WS from my Spring Controller by passing my Appointment Data as a json Object via RestTemplate:
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 need to decide if you want to use some kind of password encryption when passing credentials from one server to another - and how you implement your error handling.