从URL中读取xml
问题描述:
我正在尝试从URL中读取xml(以及它的非URL,它的宁静服务),下面是我的代码。我不知道问题是什么,但我无法从URL读取XML。我得到的错误,我没有得到任何数据..从URL中读取xml
string soap = "";
if (fPortalGuid != string.Empty)
{
HttpWebRequest request = WebRequest.Create("http://cramapp-dt-02s.cable.comcast.com:8158/restfulqueryservice/queryservice/getrequestdetails?api_key=......&request_id=33ebc6e9-9def-4f39-adf9-bba2edef3b54") as HttpWebRequest;
//request.Credentials = new NetworkCredential("rolland", "409cleaner");
//request.ContentType = "application/json; charset = utf - 8";
request.Method = "POST";
using (Stream stm = request.GetRequestStream())
{
using (StreamWriter stmw = new StreamWriter(stm))
{
stmw.Write(soap);
}
}
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
Console.WriteLine(reader.ReadToEnd());
}
}
和XML看起来像这样
答
这条线可以使错误
HttpWebRequest request = WebRequest.Create("http://cramapp-dt-02s.cable.comcast.com:8158/restfulqueryservice/queryservice/getrequestdetails?api_key=......&request_id=33ebc6e9-9def-4f39-adf9-bba2edef3b54") as HttpWebRequest;
因为在创建功能的网址(太长,所以有...呼喊显示),请尝试找到并粘贴完整链接或此链接:
http://www.w3schools.com/xml/note.xml
+1
不要太长;只是隐藏他的API密钥。 –
+0
是的,我隐藏我的api键:) – Philly
你有什么错误? – Bobson
您确定您的界面接受POST请求?尝试做一个GET。 –
你是如何得到你在截图中显示的XML的? XML上面的消息“The XML file does not appear ...”只是浏览器警告你,它显示的XML是内部样式表,而不是Web服务的错误。如果您在C#代码中遇到异常,请提供。 –