【问题标题】:Exchange Web Services, Create All Day Appt in another Time ZoneExchange Web Services,在另一个时区创建全天 Appt
【发布时间】:2011-12-17 07:32:33
【问题描述】:

交换和时区将是我的死亡。

我的 Exchange Server 位于美国东部标准时间 (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 天。

如果我从 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 上下文标头),它只会跨越一天。

【问题讨论】:

    标签: web-services soap exchange-server exchangewebservices


    【解决方案1】:

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

    <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>
    

    【讨论】:

    猜你喜欢
    • 2011-12-11
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 2010-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多