Web services 401访问web服务时出错 我试图使用ASP.NET./P>从SharePoint基金会2010中消费Web服务。

Web services 401访问web服务时出错 我试图使用ASP.NET./P>从SharePoint基金会2010中消费Web服务。,web-services,sharepoint-2010,Web Services,Sharepoint 2010,我收到一个401未经授权的错误 我知道这意味着凭据丢失或无效,但我似乎无法找到原因 我可以从标准浏览器访问web服务页面,无需身份验证,这对用户/密码没有任何挑战。这可以从服务器本身以及远程客户端浏览器中工作 代码如下: Dim wsLists As New JEMS30LISTS.Lists Dim dtTasks As New DataTable Dim xmlDoc As New System.Xml.XmlDocument Dim ndQuery, ndV

我收到一个401未经授权的错误

我知道这意味着凭据丢失或无效,但我似乎无法找到原因

我可以从标准浏览器访问web服务页面,无需身份验证,这对用户/密码没有任何挑战。这可以从服务器本身以及远程客户端浏览器中工作

代码如下:

    Dim wsLists As New JEMS30LISTS.Lists
    Dim dtTasks As New DataTable
    Dim xmlDoc As New System.Xml.XmlDocument
    Dim ndQuery, ndViewFields, ndQueryOptions, ndListItems As System.Xml.XmlNode
    Dim szListName, szListsUrl, szUsername, szPassword, szDomain As String
    szListsUrl = "https://demo.********.com/_vti_bin/Lists.asmx"
    szUsername = "*********"
    szPassword = "************"
    szDomain = "***********"


    ndQuery = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "Query", "")
    ndViewFields = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "ViewFields", "")
    ndQueryOptions = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "QueryOptions", "")
    ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" _
                            + "<DateInUtc>TRUE</DateInUtc>"
    If bAllFields = True Then
        ndViewFields.InnerXml = ""
    Else
        ndViewFields.InnerXml = "<FieldRef Name=""TEAS_x0020_5_x0020_Task_x0020_Nu"" /> <FieldRef Name=""TEAS_x0020_5_x0020_SubTask"" /> <FieldRef Name=""TEAS_x0020_6_x0020_Task_x0020_Nu"" /> <FieldRef Name=""TEAS_x0020_6_x0020_Task_x0020_Nu0"" /> <FieldRef Name=""Shreds_x0020_Converted"" /> <FieldRef Name=""TEAS_x0020_6_x0020_Shred_x0020_P"" /> <FieldRef Name=""ProcessTask"" /> <FieldRef Name=""TEAS6Dept"" /> "
    End If

    ndQuery.InnerXml = "<OrderBy><FieldRef Name=""TEAS_x0020_5_x0020_Task_x0020_Nu"" Ascending=""True""></FieldRef></OrderBy>"
    szListName = "CORs"

    Try
        Dim cache As New System.Net.CredentialCache
        wsLists.Url = szListsUrl
        Dim vUri As New Uri(wsLists.Url)
        Dim vNW As New Net.NetworkCredential()
        cache.Add(vUri, "windows", vNW)
        wsLists.Credentials = cache
        ndListItems = wsLists.GetListItems(szListName, Nothing, ndQuery, ndViewFields, 99999, ndQueryOptions, Nothing)
    Catch ex As Exception
        Response.Write("GetListItems: " + ex.Message + "<br>")
    End Try
Dim wslist作为新的JEMS30LISTS.list
将dtTasks设置为新数据表
Dim xmlDoc作为新的System.Xml.XmlDocument
将ndQuery、ndViewFields、ndQueryOptions、ndListItems设置为System.Xml.XmlNode
Dim szListName、szListsUrl、szUsername、szPassword、szDomain As字符串
szListsUrl=”https://demo.********.com/_vti_bin/Lists.asmx“
szUsername=“**********”
szPassword=“*************”
szDomain=“***********”
ndQuery=xmlDoc.CreateNode(System.Xml.XmlNodeType.Element,“Query”,“”)
ndViewFields=xmlDoc.CreateNode(System.Xml.XmlNodeType.Element,“ViewFields”,“”)
ndQueryOptions=xmlDoc.CreateNode(System.Xml.XmlNodeType.Element,“QueryOptions”,“”)
ndQueryOptions.InnerXml=“FALSE”_
+“对”
如果bAllFields=True,则
ndViewFields.InnerXml=“”
其他的
ndViewFields.InnerXml=“”
如果结束
ndQuery.InnerXml=“”
szListName=“CORs”
尝试
Dim缓存为新System.Net.CredentialCache
wsLists.Url=szListsUrl
将vUri设置为新Uri(wslist.Url)
Dim vNW作为新的Net.NetworkCredential()
cache.Add(vUri,“windows”,vNW)
wsLists.Credentials=缓存
ndListItems=wsLists.GetListItems(szListName,Nothing,ndQuery,ndViewFields,99999,ndQueryOptions,Nothing)
特例
响应。写入(“GetListItems:+ex.Message+”
) 结束尝试
我尝试了几种用户名/密码组合,而且根本没有身份验证(因为我没有受到浏览器的挑战)

谁能告诉我我错过了什么


谢谢,基本授权被禁用了。我不知道这有什么关系,因为我甚至尝试了Windows授权(已启用),但也不起作用

已打开基本授权,它现在可以工作了