菜鸟教程小白 发表于 2022-12-13 12:38:44

ios - 开发 Carddav/Caldav 服务器。同步后,事件在 iOS 客户端消失


                                            <p><p>我目前正在开发一个 carddav/caldav 服务器。我已经可以在 windows/windows phone/android 上与很多客户端进行通信。现在我尝试与 iOS 同步。地址簿同步工作正常,但日历应用程序的行为很奇怪。它同步所有日历和约会并正确显示它们。它甚至将事件的参与者链接到地址簿中的联系人。但是一旦同步完成,日历和约会就会完全消失。有人有提示吗?</p>

<p>我的测试设备是装有 iOS 8.3 (12F69) 的 iPad 2。 </p>

<p>这里是交流。我忽略了没有授权 header 的请求。我还必须编辑主机名,但在所有请求中都是相同的。</p>

<p>iOS 询问的很多属性我都没有回答。但由于所有约会都在短时间内正确显示,因此不需要这些。还有很多不是 caldav 规范的一部分(但仍然放在同一个 xmlns 中?)。</p>

<h1>初步建议</h1>

<h2>请求</h2>

<pre><code>PROPFIND host:9998/.well-known/caldav HTTP/1.1
Host: host:9998
User-Agent: iOS/8.3 (12F69) accountsd/1.0
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Accept: */*
Content-Type: text/xml
Prefer: return=minimal
Depth: 0
Connection: keep-alive
Authorization: Basic ZmdoZ2poZ2g6a2dmZ2hqaA==
Content-Length: 181
Brief: t

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;A:propfind xmlns:A=&#34;DAV:&#34;&gt;
&lt;A:prop&gt;
    &lt;A:current-user-principal/&gt;
    &lt;A:principal-URL/&gt;
    &lt;A:resourcetype/&gt;
&lt;/A:prop&gt;
&lt;/A:propfind&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Content-Length: 791
Date: Tue, 15 Dec 2015 08:25:22 GMT

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:resourcetype&gt;
          &lt;d:collection/&gt;
      &lt;/d:resourcetype&gt;
      &lt;d:current-user-principal&gt;
          &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/d:current-user-principal&gt;
      &lt;d:principal-url&gt;
          &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/d:principal-url&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<h1>选项</h1>

<h2>请求</h2>

<pre><code>OPTIONS http://host:9998/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/ HTTP/1.1
Host: host:9998
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Accept-Encoding: gzip, deflate
Accept: */*
Content-Length: 0
Accept-Language: de-de
Connection: keep-alive
User-Agent: iOS/8.3 (12F69) accountsd/1.0
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Content-Length: 0
Date: Tue, 15 Dec 2015 08:25:22 GMT
</code></pre>

<h1>Propfind(这里很多属性我不回答)</h1>

<h2>请求</h2>

<pre><code>PROPFIND host:9998/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/ HTTP/1.1
Host: host:9998
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Accept: */*
Content-Type: text/xml
Prefer: return=minimal
Depth: 0
Connection: keep-alive
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Content-Length: 743
Brief: t
</code></pre>



<pre><code>&lt;A:propfind xmlns:A=&#34;DAV:&#34;&gt;
&lt;A:prop&gt;
    &lt;B:calendar-home-set xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;B:calendar-user-address-set xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;A:current-user-principal/&gt;
    &lt;A:displayname/&gt;
    &lt;C:dropbox-home-URL xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:email-address-set xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:notification-URL xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;A:principal-collection-set/&gt;
    &lt;A:principal-URL/&gt;
    &lt;A:resource-id/&gt;
    &lt;B:schedule-inbox-URL xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;B:schedule-outbox-URL xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;A:supported-report-set/&gt;
&lt;/A:prop&gt;
&lt;/A:propfind&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Content-Length: 958
Date: Tue, 15 Dec 2015 08:25:48 GMT

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:displayname&gt;Robert Glaser&lt;/d:displayname&gt;
      &lt;d:current-user-principal&gt;
          &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/d:current-user-principal&gt;
      &lt;cal:calendar-home-set&gt;
          &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/cal:calendar-home-set&gt;
      &lt;d:principal-url&gt;
          &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/d:principal-url&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<h1>建议</h1>

<h2>请求</h2>

<pre><code>PROPFIND http://host:9998/.well-known/carddav/DEVELOPMENT/principals/Robert%20Glaser/ HTTP/1.1
Host: host:9998
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Accept: */*
Content-Type: text/xml
Prefer: return=minimal
Depth: 0
Connection: keep-alive
Authorization: Basic Z2poZ2o6amhqamo=
Content-Length: 439
Brief: t

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;A:propfind xmlns:A=&#34;DAV:&#34;&gt;
&lt;A:prop&gt;
    &lt;D:addressbook-home-set xmlns:D=&#34;urn:ietf:params:xml:ns:carddav&#34;/&gt;
    &lt;D:directory-gateway xmlns:D=&#34;urn:ietf:params:xml:ns:carddav&#34;/&gt;
    &lt;A:displayname/&gt;
    &lt;C:email-address-set xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;A:principal-collection-set/&gt;
    &lt;A:principal-URL/&gt;
    &lt;A:resource-id/&gt;
    &lt;A:supported-report-set/&gt;
&lt;/A:prop&gt;
&lt;/A:propfind&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Content-Length: 795
Date: Tue, 15 Dec 2015 08:25:48 GMT

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/carddav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:displayname&gt;Robert Glaser&lt;/d:displayname&gt;
      &lt;card:addressbook-home-set&gt;
          &lt;d:href&gt;/.well-known/carddav/DEVELOPMENT/addressbooks/&lt;/d:href&gt;
      &lt;/card:addressbook-home-set&gt;
      &lt;d:principal-url&gt;
          &lt;d:href&gt;/.well-known/carddav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/d:principal-url&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<h1>建议</h1>

<h2>请求</h2>

<pre><code>PROPFIND http://host:9998/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/ HTTP/1.1
Host: host:9998
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Accept: */*
Content-Type: text/xml
Prefer: return=minimal
Depth: 1
Connection: keep-alive
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Content-Length: 2097
Brief: t

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;A:propfind xmlns:A=&#34;DAV:&#34;&gt;
&lt;A:prop&gt;
    &lt;A:add-member/&gt;
    &lt;C:allowed-sharing-modes xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;F:autoprovisioned xmlns:F=&#34;http://apple.com/ns/ical/&#34;/&gt;
    &lt;E:bulk-requests xmlns:E=&#34;http://me.com/_namespace/&#34;/&gt;
    &lt;F:calendar-color xmlns:F=&#34;http://apple.com/ns/ical/&#34;/&gt;
    &lt;B:calendar-description xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;B:calendar-free-busy-set xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;F:calendar-order xmlns:F=&#34;http://apple.com/ns/ical/&#34;/&gt;
    &lt;B:calendar-timezone xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;A:current-user-privilege-set/&gt;
    &lt;B:default-alarm-vevent-date xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;B:default-alarm-vevent-datetime xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;A:displayname/&gt;
    &lt;C:getctag xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;F:language-code xmlns:F=&#34;http://apple.com/ns/ical/&#34;/&gt;
    &lt;F:location-code xmlns:F=&#34;http://apple.com/ns/ical/&#34;/&gt;
    &lt;A:owner/&gt;
    &lt;C:pre-publish-url xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:publish-url xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:push-transports xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:pushkey xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;A:quota-available-bytes/&gt;
    &lt;A:quota-used-bytes/&gt;
    &lt;F:refreshrate xmlns:F=&#34;http://apple.com/ns/ical/&#34;/&gt;
    &lt;A:resource-id/&gt;
    &lt;A:resourcetype/&gt;
    &lt;B:schedule-calendar-transp xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;B:schedule-default-calendar-URL xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;C:source xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:subscribed-strip-alarms xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:subscribed-strip-attachments xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:subscribed-strip-todos xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;B:supported-calendar-component-set xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;B:supported-calendar-component-sets xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;A:supported-report-set/&gt;
    &lt;A:sync-token/&gt;
&lt;/A:prop&gt;
&lt;/A:propfind&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Content-Length: 2984
Date: Tue, 15 Dec 2015 08:25:49 GMT

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:resourcetype&gt;
          &lt;d:collection/&gt;
      &lt;/d:resourcetype&gt;
      &lt;cs:getctag/&gt;
      &lt;d:displayname&gt;Robert Glaser&lt;/d:displayname&gt;
      &lt;d:current-user-privilege-set&gt;
          &lt;d:privilege&gt;
            &lt;d:all/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:read/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:read-acl/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:write/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:write-content/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:read-current-user-privilege-set/&gt;
          &lt;/d:privilege&gt;
      &lt;/d:current-user-privilege-set&gt;
      &lt;d:owner&gt;
          &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/d:owner&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:resourcetype&gt;
          &lt;d:collection/&gt;
          &lt;cal:calendar/&gt;
      &lt;/d:resourcetype&gt;
      &lt;cs:getctag&gt;669801837942&lt;/cs:getctag&gt;
      &lt;d:displayname&gt;Alle Termine&lt;/d:displayname&gt;
      &lt;d:supported-report-set&gt;
          &lt;d:supported-report&gt;
            &lt;d:report&gt;
            &lt;cal:calendar-multiget/&gt;
            &lt;/d:report&gt;
          &lt;/d:supported-report&gt;
          &lt;d:supported-report&gt;
            &lt;d:report&gt;
            &lt;cal:calendar-query/&gt;
            &lt;/d:report&gt;
          &lt;/d:supported-report&gt;
      &lt;/d:supported-report-set&gt;
      &lt;d:current-user-privilege-set&gt;
          &lt;d:privilege&gt;
            &lt;d:all/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:read/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:read-acl/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:write/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:write-content/&gt;
          &lt;/d:privilege&gt;
          &lt;d:privilege&gt;
            &lt;d:read-current-user-privilege-set/&gt;
          &lt;/d:privilege&gt;
      &lt;/d:current-user-privilege-set&gt;
      &lt;cal:supported-calendar-component-set&gt;
          &lt;cal:comp name=&#34;VEVENT&#34;/&gt;
          &lt;cal:comp name=&#34;VTIMEZONE&#34;/&gt;
      &lt;/cal:supported-calendar-component-set&gt;
      &lt;d:owner&gt;
          &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
      &lt;/d:owner&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<h1>Proppatch(未实现</h1>

<h2>请求</h2>

<pre><code>PROPPATCH http://host:9998/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/ HTTP/1.1
Host: host:9998
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Accept-Encoding: gzip, deflate
Content-Type: text/xml
Accept-Language: de-de
Content-Length: 198
Accept: */*
Connection: keep-alive
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;A:propertyupdate xmlns:A=&#34;DAV:&#34;&gt;&lt;A:set&gt;&lt;A:prop&gt;&lt;F:calendar-order xmlns:F=&#34;http://apple.com/ns/ical/&#34;&gt;0&lt;/F:calendar-order&gt;&lt;/A:prop&gt;&lt;/A:set&gt;&lt;/A:propertyupdate&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 501 Not Implemented
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1029
Date: Tue, 15 Dec 2015 08:25:49 GMT
Connection: close

&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/8.0.24 - Error report&lt;/title&gt;&lt;style type=&#34;text/css&#34;&gt;H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 501 - &lt;/h1&gt;&lt;div class=&#34;line&#34;&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The server does not support the functionality needed to fulfill this request.&lt;/u&gt;&lt;/p&gt;&lt;hr class=&#34;line&#34;&gt;&lt;h3&gt;Apache Tomcat/8.0.24&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>

<h1>建议</h1>

<h2>请求</h2>

<pre><code>PROPFIND http://host:9998/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/ HTTP/1.1
Host: host:9998
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Accept: */*
Content-Type: text/xml
Prefer: return=minimal
Depth: 0
Connection: keep-alive
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Content-Length: 267
Brief: t

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;A:propfind xmlns:A=&#34;DAV:&#34;&gt;
&lt;A:prop&gt;
    &lt;B:calendar-user-address-set xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;/&gt;
    &lt;A:displayname/&gt;
    &lt;C:email-address-set xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
&lt;/A:prop&gt;
&lt;/A:propfind&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Content-Length: 500
Date: Tue, 15 Dec 2015 08:25:49 GMT

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/principals/Robert%20Glaser/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:displayname&gt;Robert Glaser&lt;/d:displayname&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<h1>MKCALENDAR(未实现)</h1>

<h2>请求</h2>

<pre><code>MKCALENDAR http://host:9998/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/B39676BE-F124-475E-9ED2-B8756951DF29/ HTTP/1.1
Host: host:9998
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Accept-Encoding: gzip, deflate
Content-Type: text/xml
Accept-Language: de-de
Content-Length: 1046
Accept: */*
Connection: keep-alive
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;B:mkcalendar xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;&gt;
&lt;A:set xmlns:A=&#34;DAV:&#34;&gt;
    &lt;A:prop&gt;
      &lt;F:calendar-order xmlns:F=&#34;http://apple.com/ns/ical/&#34;&gt;0&lt;/F:calendar-order&gt;
      &lt;B:calendar-timezone&gt;BEGIN:VCALENDAR&amp;#13;
VERSION:2.0&amp;#13;
CALSCALE:GREGORIAN&amp;#13;
BEGIN:VTIMEZONE&amp;#13;
TZID:Europe/Berlin&amp;#13;
BEGIN:DAYLIGHT&amp;#13;
TZOFFSETFROM:+0100&amp;#13;
TZNAME:MESZ&amp;#13;
TZOFFSETTO:+0200&amp;#13;
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU&amp;#13;
DTSTART:19810329T020000&amp;#13;
END:DAYLIGHT&amp;#13;
BEGIN:STANDARD&amp;#13;
TZOFFSETFROM:+0200&amp;#13;
TZNAME:MEZ&amp;#13;
TZOFFSETTO:+0100&amp;#13;
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU&amp;#13;
DTSTART:19961027T030000&amp;#13;
END:STANDARD&amp;#13;
END:VTIMEZONE&amp;#13;
END:VCALENDAR&amp;#13;
&lt;/B:calendar-timezone&gt;
      &lt;A:displayname&gt;Erinnerungen&lt;/A:displayname&gt;
      &lt;B:calendar-free-busy-set&gt;
      &lt;NO/&gt;
      &lt;/B:calendar-free-busy-set&gt;
      &lt;B:supported-calendar-component-set&gt;
      &lt;B:comp name=&#34;VTODO&#34;/&gt;
      &lt;/B:supported-calendar-component-set&gt;
    &lt;/A:prop&gt;
&lt;/A:set&gt;
&lt;/B:mkcalendar&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 501 Not Implemented
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1029
Date: Tue, 15 Dec 2015 08:25:49 GMT
Connection: close

&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/8.0.24 - Error report&lt;/title&gt;&lt;style type=&#34;text/css&#34;&gt;H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 501 - &lt;/h1&gt;&lt;div class=&#34;line&#34;&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The server does not support the functionality needed to fulfill this request.&lt;/u&gt;&lt;/p&gt;&lt;hr class=&#34;line&#34;&gt;&lt;h3&gt;Apache Tomcat/8.0.24&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>

<h1>Propfind(在日历上,我这里不回答同步 token )</h1>

<pre><code>PROPFIND http://host:9998/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/ HTTP/1.1
Host: host:9998
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Accept: */*
Content-Type: text/xml
Prefer: return=minimal
Depth: 0
Connection: keep-alive
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Content-Length: 181
Brief: t

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;A:propfind xmlns:A=&#34;DAV:&#34;&gt;
&lt;A:prop&gt;
    &lt;C:getctag xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;A:sync-token/&gt;
&lt;/A:prop&gt;
&lt;/A:propfind&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Content-Length: 507
Date: Tue, 15 Dec 2015 08:25:51 GMT

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;cs:getctag&gt;669801837942&lt;/cs:getctag&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<h1>Propfind(查找所有约会)</h1>

<h2>请求</h2>

<pre><code>PROPFIND host:9998/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/ HTTP/1.1
Host: host:9998
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Accept: */*
Content-Type: text/xml
Prefer: return=minimal
Depth: 1
Connection: keep-alive
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Content-Length: 145
Brief: t

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;A:propfind xmlns:A=&#34;DAV:&#34;&gt;
&lt;A:prop&gt;
    &lt;A:getcontenttype/&gt;
    &lt;A:getetag/&gt;
&lt;/A:prop&gt;
&lt;/A:propfind&gt;
</code></pre>

<h2>响应(响应中有更多约会,我在这里只显示第一个,但它们看起来都一样,不同的hrefs)</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml
Transfer-Encoding: chunked
Date: Tue, 15 Dec 2015 08:25:54 GMT

2000
&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop/&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/0075712608923743A35868DB6A589A31.ics&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:getetag&gt;1241532994&lt;/d:getetag&gt;
      &lt;d:getcontenttype&gt;text/calendar&lt;/d:getcontenttype&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<h1>报告(下载所有约会,再次省略其他href)</h1>

<h2>请求</h2>

<pre><code>REPORT http://host:9998/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/ HTTP/1.1
Host: host:9998
Authorization: Basic bW5iam5ia2tqaHZmOm1oZ2o=
Accept-Encoding: gzip, deflate
Content-Type: text/xml
Accept-Language: de-de
Content-Length: 7677
Accept: */*
Connection: keep-alive
User-Agent: iOS/8.3 (12F69) dataaccessd/1.0

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;B:calendar-multiget xmlns:B=&#34;urn:ietf:params:xml:ns:caldav&#34;&gt;
&lt;A:prop xmlns:A=&#34;DAV:&#34;&gt;
    &lt;A:getetag/&gt;
    &lt;B:calendar-data/&gt;
    &lt;C:created-by xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;C:updated-by xmlns:C=&#34;http://calendarserver.org/ns/&#34;/&gt;
    &lt;B:schedule-tag/&gt;
&lt;/A:prop&gt;
&lt;A:href xmlns:A=&#34;DAV:&#34;&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/50EAF942E0AB35A1B81792F7AAB6027E.ics&lt;/A:href&gt;
&lt;/B:calendar-multiget&gt;
</code></pre>

<h2>响应</h2>

<pre><code>HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, REPORT
DAV: 1, 3, extended-mkcol, addressbook, access-control, calendar-access
MS-Author-Via: DAV
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Accept-Ranges: bytes
Content-Type: text/xml;charset=utf-8
Date: Tue, 15 Dec 2015 08:25:58 GMT
Content-Length: 58259

&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;d:multistatus xmlns:d=&#34;DAV:&#34; xmlns:cal=&#34;urn:ietf:params:xml:ns:caldav&#34; xmlns:card=&#34;urn:ietf:params:xml:ns:carddav&#34; xmlns:cs=&#34;http://calendarserver.org/ns/&#34;&gt;
&lt;d:response&gt;
    &lt;d:href&gt;/.well-known/caldav/DEVELOPMENT/calendars/Robert%20Glaser/Alle%20Termine/50EAF942E0AB35A1B81792F7AAB6027E.ics&lt;/d:href&gt;
    &lt;d:propstat&gt;
      &lt;d:prop&gt;
      &lt;d:getetag&gt;1447948122&lt;/d:getetag&gt;
      &lt;cal:calendar-data&gt;BEGIN:VCALENDAR&amp;#13;
CALSCALE:GREGORIAN&amp;#13;
VERSION:2.0&amp;#13;
PRODID:-//DE/RND/DAV/CALDAV &amp;#13;
BEGIN:VEVENT&amp;#13;
DTSTAMP:20151215T082555Z&amp;#13;
CLASS:PUBLIC&amp;#13;
DESCRIPTION:&amp;#13;
DTSTART:20151120T070000Z&amp;#13;
DTEND:20151120T073000Z&amp;#13;
SUMMARY:NeuerMehrTeilnehmerTermin&amp;#13;
TRANSP:OPAQUE&amp;#13;
ATTENDEE;CN=Robert Glaser;PARTSTAT=ACCEPTED:mailto:[email protected]&amp;#13;
RESOURCES:Audi A6&amp;#13;
UID:50EAF942E0AB35A1B81792F7AAB6027E&amp;#13;
CREATED:20151119T154839Z&amp;#13;
LAST-MODIFIED:20151119T154839Z&amp;#13;
END:VEVENT&amp;#13;
END:VCALENDAR&amp;#13;
&lt;/cal:calendar-data&gt;
      &lt;/d:prop&gt;
      &lt;d:status&gt;HTTP/1.1 200 OK&lt;/d:status&gt;
    &lt;/d:propstat&gt;
&lt;/d:response&gt;
&lt;/d:multistatus&gt;
</code></pre>

<p>在此之后,还有 4 个 REPORT 请求来获取所有约会。
之后,在主机的根目录中有一个 propfind 请求,由于 30.000 个字符的限制,我无法发布该请求。我无法回答这个请求,因为它没有到达我的 servlet。</p>

<p>感谢您的帮助。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>今天,我终于可以修复错误了。在第一个请求中,ios 要求提供 principal-<strong>URL</strong>,我用 principal-<strong>url</strong> 回答。此标记名的最后一部分必须用大写字母书写,才能被 iOS 识别。它使用 URL 在同步后向委托(delegate)人发出一个(在我看来毫无意义的)请求。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 开发 Carddav/Caldav 服务器。同步后,事件在 iOS 客户端消失,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/34269944/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/34269944/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 开发 Carddav/Caldav 服务器。同步后,事件在 iOS 客户端消失