Re: Event sink registration via WebDAV
- From: "Henning Krause" <hkrause.no@xxxxxxxxxxxxxxxxx>
- Date: Mon, 4 Sep 2006 16:30:55 +0200
Hello,
I don't know if you have set all properties... but MKCOL is definitely the wrong method.
Use PROPPATCH instead - the event item is an item, not a folder.
Best regards,
Henning Krause
----------------------------------------------------------------------------
Visit my website: http://www.infinitec.de
Exchange access library - http://www.infinitec.de/software/nettoolbox/infinitec.exchange.aspx
"Martin Komischke" <makom.news@xxxxxxxx> wrote in message news:44fc1fe5$0$5158$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I have changed some example code for registering an exchange-event-sink, but it doesnt work! Can somebody please tell me what is wrong here?
The exception: "The remote server returned an error (405) Method not allowed" at line 68.
public static void RegisterEventSink()
{
try
{
string myUserName = "user1";
string myPassword = "user1";
string myDomain = "Domain";
string myExchange = "http://exdevel2k3/exchange/";
string myUri = myExchange + myUserName + "/Inbox/";
// Create a new CredentialCache object and fill it with the network
// credentials required to access the server.
CredentialCache myCredentialCache = new System.Net.CredentialCache();
myCredentialCache.Add(new System.Uri(myUri),
"NTLM",
new System.Net.NetworkCredential(myUserName, myPassword, myDomain)
);
System.Uri Uri = new System.Uri(myUri);
HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create(Uri);
string strQuery;
strQuery = "<?xml version=\"1.0\"?>";
strQuery += "<g:propertyupdate xmlns:g='DAV:' xmlns:ev='http://schemas.microsoft.com/exchange/events/'>";
strQuery += "<g:set><g:prop>";
strQuery += "<g:contentclass>urn:content-class:storeeventreg</g:contentclass>";
strQuery += "<ev:EventMethod>OnSyncSave</ev:EventMethod>";
strQuery += "<ev:SinkClass>TPMExEvents.TPMExEv.1</ev:SinkClass>";
strQuery += "<ev:matchScope>SHALLOW</ev:matchScope>";
strQuery += "</g:prop></g:set>";
strQuery += "</g:propertyupdate>";
HttpWRequest.Credentials = myCredentialCache;
// Set Headers
HttpWRequest.KeepAlive = false;
HttpWRequest.Headers.Set("Pragma", "no-cache");
HttpWRequest.ContentType = "text/xml";
HttpWRequest.ContentLength = strQuery.Length;
// Set the request timeout to 5 minutes
HttpWRequest.Timeout = 300000;
// Set the request method
HttpWRequest.Method = "MKCOL";
// Store the data in a byte array
byte[] ByteQuery = System.Text.Encoding.ASCII.GetBytes(strQuery);
HttpWRequest.ContentLength = ByteQuery.Length;
Stream QueryStream = HttpWRequest.GetRequestStream();
// Write the data to be posted to the Request Stream
QueryStream.Write(ByteQuery, 0, ByteQuery.Length);
QueryStream.Close();
// Send Request and Get Response
HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWRequest.GetResponse();//<-- Exception here (l.68)
// Get the Status code
int iStatCode = (int)HttpWResponse.StatusCode;
string sStatus = iStatCode.ToString();
Console.WriteLine("Status Code: {0}", sStatus);
// Get the request headers
string sReqHeaders = HttpWRequest.Headers.ToString();
Console.WriteLine(sReqHeaders);
// Read the Response Steam
Stream strm = HttpWResponse.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string sText = sr.ReadToEnd();
Console.WriteLine("Response: {0}", sText);
// Close Stream
strm.Close();
// Clean Up
myCredentialCache = null;
HttpWRequest = null;
HttpWResponse = null;
QueryStream = null;
strm = null;
sr = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
.
- Follow-Ups:
- Re: Event sink registration via WebDAV
- From: Martin Komischke
- Re: Event sink registration via WebDAV
- References:
- Event sink registration via WebDAV
- From: Martin Komischke
- Event sink registration via WebDAV
- Prev by Date: Event sink registration via WebDAV
- Next by Date: Re: Event sink registration via WebDAV
- Previous by thread: Event sink registration via WebDAV
- Next by thread: Re: Event sink registration via WebDAV
- Index(es):
Relevant Pages
|