Creating an appointment in an exchange calendar using webdav (slide)

B

Bernhard Weitlaner

Hello!

I am new in webdav. I am trying for a long time to create an appointment in
an exchange calendar (pubic folder) using webdav but without success.
I am despairing.
Here my programm:

String strCalendarURI = "http://server/public/test1";
HttpURL hrl = new HttpURL(strCalendarURI);
hrl.setUserinfo("user", "pw");
WebdavResource wdr = new WebdavResource(hrl);

wdr.setDebug(1);
Hashtable props = new Hashtable();
props.put(new PropertyName("DAV:", "contentclass"),
"urn:content-classes:appointment");
props.put(new PropertyName("DAV:", "contentclass"),
"urn:content-classes:appointment");
props.put(new PropertyName("http//schemas.microsoft.com/exchange",
"outlookmessageclass"), "IPM.Appointment");
props.put(new PropertyName("urn:schemas:httpmail","subject"), "Changed
Test Appointment Subject");
props.put(new PropertyName("urn:schemas:httpmail","htmldescription"),
"Let's meet here");
props.put(new PropertyName("urn:schemas:calendar","location"), "do");
props.put(new PropertyName("urn:schemas:calendar","dtstart"),
"2006-01-01T10:00:00.000Z");
props.put(new PropertyName("urn:schemas:calendar", "dtend"),
"2006-01-01T10:30:00.000Z");
props.put(new PropertyName("urn:schemas:calendar","instancetype"), "0");
props.put(new PropertyName("urn:schemas:calendar","alldayevent"), "0");
props.put(new PropertyName("urn:schemas:calendar","responserequested"),
"1");
props.put(new PropertyName("urn:schemas:calendar","busystatus"), "BUSY");
props.put(new PropertyName("urn:schemas:calendar","meetingstatus"),
"CONFIRMED");
props.put(new PropertyName("header", "to"), "user");
props.put(new PropertyName("urn:schemas:mapi","finvited"), "1");

out.print("returned value ... " + wdr.proppatchMethod(props, true));


The output:

PROPPATCH /public/test1 HTTP/1.1
Authorization: Basic Qi5XZWl0bGFuZXI6c3NvYg==
Content-Type: text/xml; charset=utf-8
User-Agent: Jakarta Commons-HttpClient/2.0final
Host: server
Content-Length: 1068

<D:propertyupdate xmlns:D="DAV:">
<D:set>
<D:prop>
<responserequested xmlns="urn:schemas:calendar">
1
</responserequested>
<dtend xmlns="urn:schemas:calendar">
2006-01-01T10:30:00.000Z
</dtend>
<meetingstatus xmlns="urn:schemas:calendar">
CONFIRMED
</meetingstatus>
<to xmlns="header">
user
</to>
<instancetype xmlns="urn:schemas:calendar">
0
</instancetype>
<outlookmessageclass xmlns="http//schemas.microsoft.com/exchange">
IPM.Appointment
</outlookmessageclass>
<location xmlns="urn:schemas:calendar">
do
</location>
<alldayevent xmlns="urn:schemas:calendar">
0
</alldayevent>
<dtstart xmlns="urn:schemas:calendar">
2006-01-01T10:00:00.000Z
</dtstart>
<htmldescription xmlns="urn:schemas:httpmail">
Let's meet here
</htmldescription>
<finvited xmlns="urn:schemas:mapi">
1
</finvited>
<D:contentclass>
urn:content-classes:appointment
</D:contentclass>
<v xmlns="urn:schemas:contacts">
1
</v>
<subject xmlns="urn:schemas:httpmail">
Changed Test Appointment Subject
</subject>
<busystatus xmlns="urn:schemas:calendar">
BUSY
</busystatus>
</D:prop>
</D:set>
</D:propertyupdate>
------------------------------------------------------------------------

<<<<<<< from server ---------------------------------------------------
HTTP/1.1 207 Multistatus
Date: Wed, 25 Jan 2006 08:38:54 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
MS-Exchange-Permanent-URL:
http://server/public/-FlatUrlSpace-/ddd97380fa9bf5429d9fdc31ddb24cd9-288e4
Repl-UID: <rid:ddd97380fa9bf5429d9fdc31ddb24cd9000000000529>
Content-Type: text/xml
Content-Length: 617
ResourceTag:
<rt:ddd97380fa9bf5429d9fdc31ddb24cd9000000000529ddd97380fa9bf5429d9fdc31ddb24cd9000000000879>
MS-WebStorage: 6.5.7638

<a:multistatus
xmlns:a="DAV:"
xmlns:b="urn:schemas:calendar"
xmlns:c="header"
xmlns:d="http//schemas.microsoft.com/exchange"
xmlns:e="urn:schemas:httpmail"
xmlns:f="urn:schemas:mapi"
xmlns:g="urn:schemas:contacts">

<a:response>
<a:href>
http://server/public/test1
</a:href>
<a:propstat>
<a:status>
HTTP/1.1 200 OK
</a:status>
<a:prop>
<b:responserequested>
</b:responserequested>
<b:dtend>
</b:dtend>
<b:meetingstatus>
</b:meetingstatus>
<c:to>
</c:to>
<b:instancetype>
</b:instancetype>
<d:eek:utlookmessageclass>
</d:eek:utlookmessageclass>
<b:location>
</b:location>
<b:alldayevent>
</b:alldayevent>
<b:dtstart>
</b:dtstart>
<e:htmldescription>
</e:htmldescription>
<f:finvited>
</f:finvited>
<a:contentclass>
</a:contentclass>
<g:v>
</g:v>
<e:subject>
</e:subject>
<b:busystatus>
</b:busystatus>
</a:prop>
</a:propstat>
</a:response>
PROPFIND /public/test1 HTTP/1.1
Authorization: Basic Qi5XZWl0bGFuZXI6c3NvYg==
Content-Type: text/xml; charset=utf-8
User-Agent: Jakarta Commons-HttpClient/2.0final
Host: server
Content-Length: 207
Depth: 0

<D:propfind xmlns:D="DAV:">
<D:prop>
<D:displayname>
</D:displayname>
<D:getcontentlength>
</D:getcontentlength>
<D:getcontenttype>
</D:getcontenttype>
<D:resourcetype>
</D:resourcetype>
<D:getlastmodified>
</D:getlastmodified>
<D:lockdiscovery>
</D:lockdiscovery>
</D:prop>
</D:propfind>
------------------------------------------------------------------------

<<<<<<< from server ---------------------------------------------------
HTTP/1.1 207 Multistatus
Date: Wed, 25 Jan 2006 08:38:54 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Content-Type: text/xml
Accept-Ranges: rows
MS-WebStorage: 6.5.7638
Transfer-Encoding: chunked

<a:multistatus
xmlns:a="DAV:"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:c="xml:">

<a:response>
<a:href>
http://server/public/test1/
</a:href>
<a:propstat>
<a:status>
HTTP/1.1 200 OK
</a:status>
<a:prop>
<a:displayname>
test1
</a:displayname>
<a:getcontentlength b:dt="int">
0
</a:getcontentlength>
<a:resourcetype>
<a:collection>
</a:collection>
</a:resourcetype>
<a:getlastmodified b:dt="dateTime.tz">
2006-01-25T08:38:54.755Z
</a:getlastmodified>
<lockdiscovery xmlns="DAV:">
</lockdiscovery>
</a:prop>
</a:propstat>
<a:propstat>
<a:status>
HTTP/1.1 404 Resource Not Found
</a:status>
<a:prop>
<a:getcontenttype>
</a:getcontenttype>
</a:prop>
</a:propstat>
</a:response>
</a:multistatus>
------------------------------------------------------------------------

It looks not so bad. But no appointment is created.
Where is the problem?
When i google for the problem i always find howtos for .NET but nearly
nothing for java

Thank you for your help.

best regards
Bernhard
 
E

Erich Oswald

Bernhard said:
Hello!

I am new in webdav. I am trying for a long time to create an appointment in
an exchange calendar (pubic folder) using webdav but without success.
I am despairing.
Here my programm:

[snipped log]
It looks not so bad. But no appointment is created.
Where is the problem?
When i google for the problem i always find howtos for .NET but nearly
nothing for java

Thank you for your help.

best regards
Bernhard

My experience has been that although you can connect to Exchange with
WebDAV, a lot of things don't work the way you'd expect when you just
read about WebDAV. Remember it's Microsoft :).

When we developed an Exchange back-end for a SyncML-DS server, we
found that we weren't able to create appointments with PROPPATCH
either. What we finally did was to sniff the WebDAV traffic between
Exchange and an Outlook Web Access (OWA) client. When we saw that OWA
uses POST requests to create new appointments, we did the same.

BTW, we also used the WebDAV client from Jakarta Slide, but quickly
found the standard WebdavResource behaviour didn't correspond to our
requirements and stopped using it. We still profited a lot from
Slide's implementations of all WebDAV methods and of course from the
excellent HttpClient base.
 
B

Bernhard Weitlaner

Hello Erich!


Thank you for your answer.
I was worry about that microsoft has their own standards once again.

I need only one function of the webdav protocol. And that is to insert
an appointment into a calendar.

You said that you tried it with the PUT method. Does that work?
Maybe do you have a small code sample?
That would be great.

Thank you very much.

regards,
Bernhard
 
E

Erich Oswald

Bernhard said:
Hello Erich!

Thank you for your answer.
I was worry about that microsoft has their own standards once again.

I need only one function of the webdav protocol. And that is to insert
an appointment into a calendar.

Ok, that will make things easier.
You said that you tried it with the PUT method. Does that work?

Not a PUT, but a POST. In addition to your regular WebDAV properties,
add a property "Cmd" with value "saveappt" (which in OWA is part of
the form).
Maybe do you have a small code sample?
That would be great.

Something like:

PostMethod post = new PostMethod("/exchange/calendar");
post.addParameter("Cmd", "saveappt");
post.addParameter("urn:schemas:calendar:dtstart", "20060126T160000Z");
....
try {
httpClient.executeMethod(post);
} catch (IOException e) {
...
}

To be honest there are a few things missing (like getting the
httpClient), but you can look up most of these things in the source of
the WebdavResource class.
Thank you very much.

regards,
Bernhard

I hope this helps.

Erich
--
 
B

Bernhard Weitlaner

Hi Erich!


It works :). I have an appointment in my calendar.
Thank you very much.

Bernhard
 
K

Ken

How did you make it? I am working on something like yours, could give
me some hints?
Thanks in advance~
 
Joined
Jul 27, 2006
Messages
1
Reaction score
0
Hi,

I have created an appointment using a POST.

Now I would like to know the uid of the appointment just created.

Have you already found a way to get this?

Regards,

Ekor.
 
Joined
Dec 28, 2007
Messages
1
Reaction score
0
Creating appointment no longer works with Exchange 2007

I have been using Post to create an appointment, but now we have upgraded to Exchange Server 2007 and this no longer works. Any ideas or suggestions?
 
Joined
Apr 30, 2009
Messages
1
Reaction score
0
Hi,

I have been struggling with the same issue of getting a success (201) response, but no appointment appearing (although I have been using .Net).

I finally found that adding the following request header "Translate: f" fixed my problem. This seems to be left out in the MSDN articles.

I didn't end up needing to add any post parameters.

I hope this helps someone.
 
Joined
Jun 1, 2009
Messages
2
Reaction score
0
Hashtable props = new Hashtable();
props.put(new PropertyName("DAV:", "contentclass"),"urn:content-classes:appointment");
props.put(new PropertyName("DAV:", "contentclass"),"urn:content-classes:appointment");
props.put(new PropertyName("http//schemas.microsoft.com/exchange","outlookmessageclass"), "IPM.Appointment");
props.put(new PropertyName("urn:schemas:httpmail","subject"), "Changed Test Appointment Subject");
props.put(new PropertyName("urn:schemas:httpmail","htmldescription"),"Let's meet here");
props.put(new PropertyName("urn:schemas:calendar","location"), "do");
props.put(new PropertyName("urn:schemas:calendar","dtstart"),"2009-06-02T10:00:00.000Z");
props.put(new PropertyName("urn:schemas:calendar", "dtend"),"2009-06-02T10:30:00.000Z");
props.put(new PropertyName("urn:schemas:calendar","instancetype" ), "0");
props.put(new PropertyName("urn:schemas:calendar","alldayevent") , "0");
props.put(new PropertyName("urn:schemas:calendar","responserequested"),"1");
props.put(new PropertyName("urn:schemas:calendar","busystatus"), "BUSY");
props.put(new PropertyName("urn:schemas:calendar","meetingstatus"),"CONFIRMED");
props.put(new PropertyName("header", "to"), "(e-mail address removed)");
props.put(new PropertyName("urn:schemas:mapi","finvited"), "1");
webdavresource.setContentType("text/xml");

System.out.print("returned value ... " + webdavresource.proppatchMethod(props, true));


HTTP/1.1 411 Length Required ????
how can i send mail ?? or add the calendar event ?
plz reply soon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top