1

如何从 servlet 获取返回值到 c#?我使用传递参数给servlet

 HttpWebRequest request = (HttpWebRequest)WebRequest
                         .Create("http://localhost:8080/value/Get_value?p_value=" + 
                                      passedValue);    
 HttpWebResponse response = (HttpWebResponse)request.GetResponse();

然后servlet将处理并将返回值传递给c#。

4

1 回答 1

1

您必须读取响应缓冲区(流)。

...
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader=new StreamReader(response.GetResponseStream()))
 {
 string line = reader.ReadToEnd();
 Console.WriteLine(line);
 }
于 2012-05-10T03:24:49.637 回答