我试图从服务器检索XML文档和本地存储它作为一个字符串.在桌面.Net我不需要,我只是做了:
string xmlFilePath = "https://myip/";
XDocument xDoc = XDocument.Load(xmlFilePath);
Run Code Online (Sandbox Code Playgroud)
但是在WP7上会返回:
Cannot open 'serveraddress'. The Uri parameter must be a relative path pointing to content inside the Silverlight application's XAP package. If you need to load content from an arbitrary Uri, please see the documentation on Loading XML content using WebClient/HttpWebRequest.
Run Code Online (Sandbox Code Playgroud)
所以,我开始使用Web客户端/ HttpWebRequest的例子,从这里,但现在它返回:
The remote server returned an error: NotFound.
Run Code Online (Sandbox Code Playgroud)
是因为XML是https路径吗?或者因为我的路径没有以.XML结尾?我怎么知道的?谢谢你的帮助.
这是代码:
public partial class MainPage : PhoneApplicationPage
{
WebClient client = new WebClient();
string baseUri = "https://myip:myport/service";
public …
Run Code Online (Sandbox Code Playgroud)