- ( java ews api), StartTimeZone Exchange 2007 1 (SP1) - Spring .
:
, Exchange 2007 SP1 StartTimeZone EWS. , Exchange 2010.
, "" Java Exchange Framework.
, , , .NET, :
Nancy.
.
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; }
}
}
WS Spring, json- 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());
, - .