WebDAV PROPFIND 的示例代码 [英] Sample code for WebDAV PROPFIND

查看:24
本文介绍了WebDAV PROPFIND 的示例代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何网站或有人可以向我提供样本 PROFIND 请求.

我尝试了 MSDN 中的 PROFIND 代码示例,但收到 400 Bad request.

无法理解为什么会发生这种情况.

之前在 Getting 400 Bad request from WebDav Server

任何建议都会非常有帮助.

编辑

@朱利安,

已将我的请求正文更新为以下内容:

 strBody = "

RFC 4918,第9.1节所述/p>

但我仍然收到 400 Bad request 错误.我错过了任何标题.请建议我设置以下标题信息:

 System.Net.HttpWebRequest 请求;Request.Credentials = MyCredentialCache;Request.Method = "PROPFIND";字节 = Encoding.UTF8.GetBytes((string)strBody);Request.ContentType = "text/xml";

我是否需要设置或指定其他内容.完整代码在我的Previosu问题中.

谢谢,

苏珊

解决方案

好吧,我错过了深度标题,因此网络服务器返回 Method Not allowed 错误.

MSDN 明确指出MAPI 客户端(如 Microsoft Outlook)可访问的公共存储不支持深度值为infinity"的 PROPFIND.

由于我没有使用代理,因此生成了错误请求 404 错误.所以我做了什么我评论了没有使用任何代理的行并添加了深度标题.

//Request.Proxy = GlobalProxySelection.GetEmptyWebProxy();Request.Headers.Add("深度", "1");

Is there any site or some one can provide me a sample PROFIND request please.

I tried the PROFIND code sample from MSDN but getting 400 Bad request.

Unable to understand why this is happening.

Previously posted the question at Getting 400 Bad request from WebDav Server

Any suggestions will be greatly helpfull.

Edit

@Julian,

Have updated my request body to the following:

 strBody = "<?xml version='1.0' encoding='utf-8'?>"
                 + "<propfind xmlns='DAV:'>"
                 + "<allprop/>"
                + "</propfind>";

as explained at RFC 4918, Section 9.1

But I am still getting the 400 Bad request Error. M I missing any Headers . Please suggest I am setting the following Header Information:

 System.Net.HttpWebRequest Request;
 Request.Credentials = MyCredentialCache;
 Request.Method = "PROPFIND";

 bytes = Encoding.UTF8.GetBytes((string)strBody);
 Request.ContentType = "text/xml";

Do I need to set or specify something additional. The full code is in my Previosu Question.

Thanks,

Subhen

解决方案

Ok I was missing the Depth Header and for that reason the webserver was returning Method Not allowed error.

MSDN clearlystates that A PROPFIND with depth value of "infinity" is not supported in the public store that is accessible to MAPI clients such as Microsoft Outlook.

And the Bad request 404 error was generated because I was not using proxy. So What I did I commented the line which was not using any proxy and added the Depth Header.

 // Request.Proxy = GlobalProxySelection.GetEmptyWebProxy();
Request.Headers.Add("Depth", "1");

这篇关于WebDAV PROPFIND 的示例代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆