Exchange Web服务,在另一个时区创建全天Appt

时间:2011-10-28 13:32:10

标签: web-services soap exchange-server exchangewebservices

交流和时区将成为我的死亡。

我的Exchange Server位于EST(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>

注意:我的计算机上的时区设置为“(UTC + 01:00)布鲁塞尔,哥本哈根,马德里,巴黎”,尽管计算机位于美国东部时间。

这是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上下文头),它只会跨越一天。

1 个答案:

答案 0 :(得分: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>