These are the methods from our XMLHTTPRequest class
public void Open(string Method, string Url, bool Asynch, string User, string
Password)
{
// check parameters
if (lgRequest != null)
throw new InvalidOperatio nException("Con nection Already open");
if (Url == "" || Url==null)
throw new ArgumentNullExc eption("URL must be specified");
System.Uri uriObj = new System.Uri(Url) ;
if (!((uriObj.Sche me == System.Uri.UriS chemeHttp) || (uriObj.Scheme ==
System.Uri.UriS chemeHttps)))
throw new ArgumentOutOfRa ngeException("U RL Scheme is not http or https");
//if (Method==null || (Method.ToUpper ()!="POST" && Method.ToUpper( )!="GET"
&& Method.ToUpper( )!="PUT" && Method.ToUpper( )!="PROPFIND" &&
Method.ToUpper( )!="PROPPATCH" && Method.ToUpper( )!="SEARCH"))
if (Method==null)
throw new ArgumentOutOfRa ngeException("M ethod argument type not defined");
lgbIsAsync = Asynch;
lgRequest = (HttpWebRequest )WebRequest.Cre ateDefault(uriO bj);
lgRequest.Metho d = Method;
lgRequest.Conte ntType = "text/xml";
if (User != "")
lgRequest.Crede ntials = new System.Net.Netw orkCredential(U ser, Password);
else
//lgRequest.Crede ntials = CredentialCache .DefaultCredent ials;
lgRequest.Crede ntials =
CredentialCache .DefaultCredent ials.GetCredent ial(uriObj, "Windows
Integrated");
uriObj = null;
lgReadyState = eReadyState.LOA DING;
}
// here are two points at which the exception may occur (but five minutes
later it may work)
public void Send(string body)
{
if (lgReadyState != eReadyState.LOA DING)
throw new InvalidOperatio nException("Sen ding a message is not allowed at
this ReadyState");
if (body != null)
{
if(lgbIsAsync)
{
lgMsg = body;
IAsyncResult res = lgRequest.Begin GetRequestStrea m(new
AsyncCallback(R eqCallback),lgR equest);
lgReadyState = eReadyState.LOA DED;
}
else
{
UTF8Encoding encoding = new UTF8Encoding();
byte[] buffer = encoding.GetByt es(body);
lgRequest.Conte ntLength = buffer.Length;
Stream stream = lgRequest.GetRe questStream(); // exception 501 (point one)
stream.Write(bu ffer,0,buffer.L ength);
stream.Close();
lgResponse = (HttpWebRespons e)lgRequest.Get Response(); // sometimes
exception 501 at this point
lgReadyState = eReadyState.COM PLETED;
}
}
}
This ist the method from our business layer (contents of str=xml data of
appointment below)
Public Shared Sub SendPersonalUrl aubAppointment( ByVal itm As Urlaubsmeldung,
ByVal User As String, ByVal Pwd As String, ByVal Subject As String, ByVal
Mailbox As String, ByVal userServer As String)
Dim strAppURLKalend er As String = "http://" + userServer +
"/Exchange/" + Mailbox + "/Kalender/" + System.Guid.New Guid.ToString + ".EML"
Dim strAppURLCalend er As String = "http://" + userServer +
"/Exchange/" + Mailbox + "/calendar/" + System.Guid.New Guid.ToString + ".EML"
Dim s As New SenderAppointme nt
With s.objProp.objPr ops
.MailSubject = itm.Urlaub
.OLEndDate = itm.OutlookEndD ate
.OLStartDate = itm.OutlookStar tDate
.TextDescriptio n = "Ich bin auf " + itm.Urlaub
End With
Dim ser As New XmlSerializer(G etType(SenderAp pointment))
Dim xml As New XMLHTTP.XMLHttp Request
Dim m As New MemoryStream
Dim sw As New XmlTextWriter(m , System.Text.Enc oding.UTF8)
Dim sr As New StreamReader(m)
ser.Serialize(m , s)
Try
xml.Open("PROPP ATCH", strAppURLKalend er, False, User, Pwd)
Catch ex1 As Exception
xml.Open("PROPP ATCH", strAppURLCalend er, False, User, Pwd)
End Try
xml.SetRequestH eader("Content-Type", "text/xml")
m.Position = 0
Dim str As String = sr.ReadToEnd
xml.Send(str)
Dim strResult As String = xml.GetResponse XML.InnerXml
xml.Dispose()
sw.Close()
End Sub
//str
"<?xml version="1.0"?>
<propertyupda te xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns="DAV:">
<set>
<prop>
<contentclass>u rn:content-classes:appoint ment</contentclass>
<outlookmessage class
xmlns="http://schemas.microso ft.com/exchange/">IPM.Appointme nt</outlookmessagec lass>
<location xmlns="urn:sche mas:calendar:" />
<dtstart
xmlns="urn:sche mas:calendar:"> 2005-09-01T00:00:00.000 0000+02:00</dtstart>
<dtend
xmlns="urn:sche mas:calendar:"> 2005-09-02T00:00:00.000 0000+02:00</dtend>
<instancetype xmlns="urn:sche mas:calendar:"> 0</instancetype>
<busystatus xmlns="urn:sche mas:calendar:"> OOF</busystatus>
<meetingstatu s xmlns="urn:sche mas:calendar:"> TENTATIVE</meetingstatus>
<alldayevent xmlns="urn:sche mas:calendar:"> 0</alldayevent>
<responsereques ted xmlns="urn:sche mas:calendar:"> 1</responserequest ed>
<method xmlns="urn:sche mas:calendar:"> REQUEST</method>
<sequence xmlns="urn:sche mas:calendar:"> 0</sequence>
<priority xmlns="urn:sche mas:httpmail:"> 0</priority>
<read xmlns="urn:sche mas:httpmail:"> 1</read>
<subject xmlns="urn:sche mas:httpmail:"> URLAUB</subject>
<textdescriptio n xmlns="urn:sche mas:httpmail:"> Ich bin auf
URLAUB</textdescription >
</prop>
</set>
</propertyupdate> "
"Joerg Jooss" wrote:
maria.s wrote:
Hi,
I try to create a calender-item in the personal calendar folder from
an ASP.NET application using XML-HTTP Request (WebDAV).
System: Windows 2003 SP1, Exchange 2003 SP1
Configuration IIS: Default Web Site stopped, OWA running on a second
virtual site, my application is running on a third virtual site.
OWA is configured for Integrated Windows Authentication only, my
application the very same. The application uses impersonate=tru e
without a userName.
The problem:
Some times access succeeds. Some times access fails with exception
501 - not implemented. The exception occurs during the attempt to
open a request stream (GetRequestStre am property of HTTPRequest
object) to the private calendar folder.
Post your code. 501 usually means that a particular HTTP method (e.g.
PUT or DELETE) isn't implemented by the server.
Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e