0

我正在尝试从 url 读取 xml(它不是 url 它的安静服务),下面是我的代码。我不知道问题是什么,但我无法从 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看起来像这样xml文件图片

4

1 回答 1

0

此行可能会出错

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;

因为 create 函数中的 url 不能访问(太长所以有 ... 用于喊显示),请尝试找到并粘贴完整链接或此链接:

http://www.w3schools.com/xml/note.xml
于 2012-10-12T18:22:21.793 回答