访问 Lists.asmx Web 服务时出现 MOSS 2007 404 错误
目前我有一个 ASP.net 4.0 应用程序,其中我对 MOSS 2007 服务器进行了 Web 引用。当我从根应用程序访问任何lists.asmx方法时,一切正常。但是,如果我尝试将 C# 代码隐藏中的服务 URL 更改为子文件夹 list.asmx 的服务 URL,然后访问 any 方法,则会收到 404 错误。但真正奇怪的是,如果我将已更改的 URL 手动插入 IE 并运行它,该服务会正常加载(按预期提供所有可用方法的列表。)
这是我的概要我正在使用的代码:
这有效:
ListsService.Lists m_listService =
ICredentials m_credentials = CredentialCache.DefaultCredentials;
m_listService.Credentials = m_credentials;
// No change to URL, defaults to 'http://mosstest/SiteDirectory/RootApp/SubApp/_vti_bin/lists.asmx'
XmlNode listColl = m_listService.GetListCollection(); // Works fine, gives me collection of lists in the root folder.
这不起作用:
ListsService.Lists m_listService =
ICredentials m_credentials = CredentialCache.DefaultCredentials;
m_listService.Credentials = m_credentials;
m_listService.Url = "http://mosstest/SiteDirectory/RootApp/SubApp/Subfolder1/_vti_bin/lists.asmx";
XmlNode listColl = m_listService.GetListCollection(); // Throws a 404 Not found error.
还有其他人遇到类似的事情吗?
Currently I have an ASP.net 4.0 app in which I've made a web reference to an MOSS 2007 server. When I access any lists.asmx methods from the root application, everything works fine. However, if I try to change the service URL in C# code-behind to that of a subfolders list.asmx, then access the any method, I get a 404 error. The really strange thing though is if I take the URL that I've changed it to and plug it manually into IE and run it, the service loads fine (giving me a list of any methods available as expected.)
Here's a rundown of my code that I'm using:
This works:
ListsService.Lists m_listService =
ICredentials m_credentials = CredentialCache.DefaultCredentials;
m_listService.Credentials = m_credentials;
// No change to URL, defaults to 'http://mosstest/SiteDirectory/RootApp/SubApp/_vti_bin/lists.asmx'
XmlNode listColl = m_listService.GetListCollection(); // Works fine, gives me collection of lists in the root folder.
This doesn't work:
ListsService.Lists m_listService =
ICredentials m_credentials = CredentialCache.DefaultCredentials;
m_listService.Credentials = m_credentials;
m_listService.Url = "http://mosstest/SiteDirectory/RootApp/SubApp/Subfolder1/_vti_bin/lists.asmx";
XmlNode listColl = m_listService.GetListCollection(); // Throws a 404 Not found error.
Anyone else run into something similar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,我试图访问列表本身,而列表本身并不是一个应用程序。我正在头头学习这个。不过我要注意的是,无论 URL 如何,通过浏览器访问时 SP 似乎都不会给出 404 错误。如果我输入类似“http://mosstest/SiteDirectory/RootApp/SubApp/Subfolder1/_vti_bin/lists.asmx”的内容,而 SubFolder1 不存在,它仍然会提供“可用”方法列表,并像服务一样运行确实在那里。不知道为什么它会这样做,但它确实引起了很大的混乱。
Turns out I was trying to access a List itself, which in turn was not an application. I'm learning this headfirst. I will note however that SP seems to not give a 404 error when accessing via the browser, regardless of the URL. If I type in something like "http://mosstest/SiteDirectory/RootApp/SubApp/Subfolder1/_vti_bin/lists.asmx", with SubFolder1 not existing, it still gives a list of methods "available" and runs as if a service was indeed there. Not sure why it does this, but it does cause a great deal of confusion.