|
|
|
date: Thu, 13 Oct 2005 13:21:03 -0700,
group: microsoft.public.exchange2000.development
back
Re: WebDav for Exchange getting 404 error
OK, I finally got it working. It looks like I played around with the XML
request string too much and had come up with something invalid. I've
corrected and got a successful response. It looks like I might not have had
spaces before the FROM, WHERE, & AND statements.
"David Tilman" wrote:
> Thanks for the response. One thing I discovered was that I had the URI string
> and request string in my WebRequest.Create() function. I've changed that and
> now I'm getting error 400 (bad request). I tried the full URL in the FROM
> statement after that and still get a 400 error.
>
> "Michael" wrote:
>
> > You have to specify full URL in the From statement like "http://Mercury/Exchange/DTilman/Inbox/" but not "/Exchange/DTilman/Inbox/"
> >
> > Michael
> > -------------------------------
> > If you need WebDAV API for Exchange server,
> > use our component WebDAV .NET for Exchange.
> > Check out http://www.independentsoft.com
> >
> >
> > "David Tilman" wrote in message news:528A36BD-4ADE-4AC6-B7CA-32C0650B1C95@microsoft.com...
> > > I've setup an ASP .NET application with a test function to try to communicate
> > > with a Exchange 2003 server with WebDav. It is the only Exchange server in
> > > the domain. I've tried a few different searches to test with and keep getting
> > > this exception:
> > >
> > > System.Net.WebException: The remote server returned an error: (404) Not Found.
> > >
> > > Here is the code:
> > >
> > > public void Search()
> > > {
> > > byte[] bytes;
> > > string strUri = "http://Mercury/Exchange/DTilman/Inbox/";
> > > string strRequest = "<?xml version=\"1.0\"?>" +
> > > "<D:searchrequest xmlns:D = \"DAV:\">" +
> > > "<D:sql>" +
> > > "SELECT \"urn:schemas:httpmail:subject\"" +
> > > "FROM \"/Exchange/DTilman/Inbox/\"" +
> > > "WHERE \"DAV:ishidden\" = false" +
> > > "AND \"DAV:isfolder\" = false" +
> > > "</D:sql>" +
> > > "</D:searchrequest>";
> > >
> > > System.Uri ExchUri = new System.Uri(strUri);
> > > HttpWebRequest wRequest = (HttpWebRequest)WebRequest.Create(ExchUri +
> > > strRequest);
> > > wRequest.KeepAlive = false;
> > > wRequest.ProtocolVersion = HttpVersion.Version11;
> > > wRequest.Headers.Set("Depth", "infinity");
> > > wRequest.ContentType = "text/xml";
> > > wRequest.Timeout = 300000;
> > > wRequest.Method = "SEARCH";
> > > NetworkCredential nwkCred = new NetworkCredential("username",
> > > "password", "domain"); //edited for forum
> > > wRequest.Credentials = nwkCred;
> > >
> > > bytes = Encoding.UTF8.GetBytes((string)strRequest);
> > > wRequest.ContentLength = bytes.Length;
> > > System.IO.Stream RequestStream = wRequest.GetRequestStream();
> > > RequestStream.Write(bytes, 0, bytes.Length);
> > > RequestStream.Close();
> > >
> > > HttpWebResponse wResponse = (HttpWebResponse)wRequest.GetResponse();
> > > }
> > >
> > > The credential code above actually contains the proper info for the user of
> > > the inbox. I can successfully get to the inbox from Outlook Web Access. Here
> > > are the log entries showing successfully accessing through OWA and failing
> > > with the ASP .NET application:
> > >
> > > Failure through application:
> > > 2005-10-13 19:26:52 192.168.90.12 SEARCH /Exchange/DTilman/Inbox/<
> > > xml%20version=%221.0%22?%3E%3CD:searchrequest%20xmlns:D%20=%20%22DAV:%22%3E%3CD:sql%3ESELECT%20%22urn:schemas:httpmail:subject%22FROM%20%22/Exchange/DTilman/Inbox/%22WHERE%20%22DAV:ishidden%22%20=%20falseAND%20%22DAV:isfolder%22%20=%20false%3C/D:sql%3E%3C/D:searchrequest%3E
> > > 80 - 192.168.12.26 - mercury 401 2 2148074254
> > >
> > > 2005-10-13 19:26:52 192.168.90.12 SEARCH /Exchange/DTilman/Inbox/<
> > > xml%20version=%221.0%22?%3E%3CD:searchrequest%20xmlns:D%20=%20%22DAV:%22%3E%3CD:sql%3ESELECT%20%22urn:schemas:httpmail:subject%22FROM%20%22/Exchange/DTilman/Inbox/%22WHERE%20%22DAV:ishidden%22%20=%20falseAND%20%22DAV:isfolder%22%20=%20false%3C/D:sql%3E%3C/D:searchrequest%3E
> > > 80 DOMAINNAME\DTilman 192.168.12.26 - mercury 404 0 0
> > >
> > > Sucess through OWA:
> > > 2005-10-13 19:00:09 192.168.55.12 SEARCH /exchange/dtilman/Inbox/ - 80
> > > DOMAINNAME\DTilman 192.168.12.26
> > > Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CLR+1.1.4322) mercury
> > > 207 0 0
> > >
> > > 2005-10-13 19:00:21 192.168.55.12 SEARCH /exchange/dtilman/Inbox/ - 80
> > > DOMAINNAME\DTilman 192.168.12.26
> > > Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CLR+1.1.4322) mercury
> > > 207 0 0
> > >
> > > I seem to authenticate correctly (no 401 error). Why am I getting a 404
> > > error though?
date: Thu, 13 Oct 2005 21:16:35 -0700
author: David Tilman
|
|