谁可以告诉我,asp.net怎么调用java 的 jsp 然后获得返回的xml啊,谢谢,大家了

解决方案 »

  1.   

    WebRequest ,HttpWebRequest ,WebClient 
      

  2.   

    不是webservice,我是通过url把用户名和密码传过去,然后那边认证,会返回一个xml
      

  3.   

    Sandy945能大概跟我讲一下吗?你上面说的是要怎么用
      

  4.   


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Height="293px" 
            Width="430px"></asp:TextBox>
        <br />
        <asp:Button ID="btn" runat="server" Text="Get XML" onclick="btn_Click" />
        </form>
    </body>
    </html>using System.Net;
    using System.IO;protected void btn_Click(object sender, EventArgs e)
        {
            string uid = "阿非", pwd = "Sandy";        WebRequest request = WebRequest.Create(string.Format("http://localhost:13655/WebSiteTest1/WebRequest/ResponseXML.aspx?uid={0}&pwd={1}", Server.UrlEncode(uid), pwd));        request.Method = "Get";        WebResponse response = request.GetResponse();             Stream stream;        if (response != null && (stream = response.GetResponseStream()) != null)
            {
                
                StreamReader sr = new StreamReader(stream, System.Text.Encoding.UTF8);            txtContent.Text = sr.ReadToEnd();
            }    }
    下面就等于jsp文件ResponseXML.aspx.csprotected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder xmlData = new StringBuilder();
            xmlData.AppendLine(@"<?xml version='1.0' encoding='UTF-8' ?>");
            xmlData.AppendLine(@"<root>");
            xmlData.AppendLine(string.Format("<uid>{0}</uid>", Request.QueryString["uid"]));
            xmlData.AppendLine(string.Format("<pwd>{0}</pwd>", Request.QueryString["pwd"]));
            xmlData.AppendLine(@"</root>");        Response.Clear();
            Response.Write(xmlData.ToString());
            Response.End();
        }
      

  5.   

    就是啊和网页抓取类似吧,用HttpWebRequest和HttpWebResponse就行了吧