我需要定期从Web服务器读取XML文件。到目前为止,我尝试了两段具有相同结果的代码......
代码1
Dim xRequest As WebRequest = WebRequest.Create(xSourceUrl)
xRequest.Proxy = New System.Net.WebProxy("ourProxy:port", True)
xRequest.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim xResponse As WebResponse = xRequest.GetResponse()
Dim xDataStream As Stream = xResponse.GetResponseStream()
Dim xReader As New StreamReader(xDataStream)
Dim xResponseFromServer As String = xReader.ReadToEnd()
xReader.Close()
xResponse.Close()
代码2
Dim xWebClient As New System.Net.WebClient()
xWebClient.Proxy = New System.Net.WebProxy("ourProxy:port", True)
xWebClient.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
xWebClient.DownloadFile(xSourceUrl, "D:\Desktop\file.txt")
我要下载的文件是网页查询的结果,例如
http://www.ceps.cz/_layouts/Ceps/_Pages/GraphData.aspx?mode=xml&from=6.5.2014%200:00:00&to=6.5.2014%2023:59:59&hasinterval=False&sol=3&lang=CZE&agr=HR&fnc=AVG&ver=RT¶1=APG&
正常下载。但是这两段代码都得到了一个不同的XML,它包含一些“Error”标签,即我没有得到我想要的东西。
答案 0 :(得分:1)
您的链接位于sharepoint服务器上,根据您获取的“错误”html的内容。请查看以下链接:
您可以在此处获取SharePoint客户端库: