Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Bernhard Weitlaner - 26 Jan 2006 09:57 GMT
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:

>>>>>>> to server ---------------------------------------------------
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:outlookmessageclass>
</d:outlookmessageclass>
<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>
</a:multistatus>
------------------------------------------------------------------------

>>>>>>> to server ---------------------------------------------------
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
Erich Oswald - 26 Jan 2006 10:28 GMT
> 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?
[quoted text clipped - 5 lines]
> 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.
Signature

Erich

Bernhard Weitlaner - 26 Jan 2006 12:12 GMT
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
Erich Oswald - 26 Jan 2006 16:01 GMT
> Hello Erich!
>
[quoted text clipped - 3 lines]
> 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
Bernhard Weitlaner - 27 Jan 2006 07:57 GMT
Hi Erich!

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

Bernhard

Erich Oswald schrieb:
>> Hello Erich!
>>
[quoted text clipped - 39 lines]
>
> Erich
Ken - 03 Feb 2006 17:25 GMT
How did you make it? I am working on something like yours, could give
me some hints?
Thanks in advance~


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.