2011-10-28 22 views
0

交换和时区将会是我的死亡。交换Web服务,在另一个时区创建全天Applet

我的Exchange服务器位于美国东部时间(UTC -5)。 Exchange版本是2007 SP1。用户位于法国巴黎(UTC +2)。如果我尝试创建预约作为全天事件,它将始终跨越2天。这里是要求:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
     <ns2:MailboxCulture xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" 
      >en-US</ns2:MailboxCulture> 
     <ns2:RequestServerVersion 
      xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" 
      Version="Exchange2007_SP1"/> 
     <ns2:TimeZoneContext xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"> 
      <ns2:TimeZoneDefinition Id="Romance Standard Time"/> 
     </ns2:TimeZoneContext> 
    </soap:Header> 
    <soap:Body> 
     <CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" 
      xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      SendMeetingInvitations="SendToAllAndSaveCopy"> 
      <SavedItemFolderId> 
       <ns2:DistinguishedFolderId Id="calendar"/> 
      </SavedItemFolderId> 
      <Items> 
       <ns2:CalendarItem> 
        <ns2:Subject>Test TZ</ns2:Subject> 
        <ns2:Body BodyType="Text"/> 
        <ns2:Start>2011-10-28T09:00:00Z</ns2:Start> 
        <ns2:End>2011-10-28T17:00:00Z</ns2:End> 
        <ns2:IsAllDayEvent>true</ns2:IsAllDayEvent> 
        <ns2:Location>Somewhere</ns2:Location> 
       </ns2:CalendarItem> 
      </Items> 
     </CreateItem> 
    </soap:Body> 
</soap:Envelope> 

注:我有时间区我的电脑设置为on“(UTC + 01:00)布鲁塞尔,哥本哈根,马德里,巴黎”,虽然计算机在物理上位于EST。

这是Outlook显示的内容,跨越2天。 What Outlook displays

如果我检索从Exchange新创建的日历项,它显示了以下开始和结束日期/时间:

<t:Start>2011-10-28T00:00:00Z</t:Start> 
<t:End>2011-10-29T00:00:00Z</t:End> 
<t:IsAllDayEvent>true</t:IsAllDayEvent> 

Entire response can be found here

我已经试过的各种组合开始和结束日期,但无论我做什么,我都会在2天内完成。如果我在EST中运行相同的东西(没有tz上下文头),它将只会跨越一天。

回答

2

好的,在这里回答我自己的问题。看起来关键在于设置会议时区。

<ns2:MeetingTimeZone> 
    <ns2:BaseOffset>-P0Y0M0DT2H0M0S</ns2:BaseOffset> 
</ns2:MeetingTimeZone> 

由于这是UTC +2,并且持续时间值必须是正值,因此将“ - ”放在“P”上。由于TZ是“UTC +2”,因此您减去2得到UTC(因此在偏移量中为负值)。如果这是EST(UTC -5),则BaseOffset将为P0Y0M0DT5H0M0S。

希望这可以帮助别人。

全部要求是这样的:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
     <ns2:MailboxCulture xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" 
      >en-US</ns2:MailboxCulture> 
     <ns2:RequestServerVersion 
      xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" 
      Version="Exchange2007_SP1"/> 
     <ns2:TimeZoneContext xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"> 
      <ns2:TimeZoneDefinition Id="Romance Standard Time"/> 
     </ns2:TimeZoneContext> 
    </soap:Header> 
    <soap:Body> 
     <CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" 
      xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" 
      SendMeetingInvitations="SendToAllAndSaveCopy"> 
      <SavedItemFolderId> 
       <ns2:DistinguishedFolderId Id="calendar"/> 
      </SavedItemFolderId> 
      <Items> 
       <ns2:CalendarItem> 
        <ns2:Subject>Test TZ</ns2:Subject> 
        <ns2:Body BodyType="Text"/> 
        <ns2:Start>2011-10-27T22:00:00Z</ns2:Start> 
        <ns2:End>2011-10-28T22:00:00Z</ns2:End> 
        <ns2:IsAllDayEvent>true</ns2:IsAllDayEvent> 
        <ns2:Location>Somewhere</ns2:Location> 
        <ns2:MeetingTimeZone> 
         <ns2:BaseOffset>-P0Y0M0DT2H0M0S</ns2:BaseOffset> 
        </ns2:MeetingTimeZone> 
       </ns2:CalendarItem> 
      </Items> 
     </CreateItem> 
    </soap:Body> 
</soap:Envelope> 
+0

去看他在哪里使用Java客户端EWS类似的情况下,我不得不改变SendInvitationsMode http://stackoverflow.com/a/20864321/448641 – vinnyjames

相关问题