0

我已经有一个在应用程序引擎中使用 java 实现的现有应用程序......现在我想从 c# 表单程序连接这个 servlet 吗?,......这是请求的试用代码

HttpWebRequest authRequest = (HttpWebRequest)HttpWebRequest.Create(googleLoginUrl);
byte[] buffer = Encoding.ASCII.GetBytes(postData);
authRequest.ContentLength = buffer.Length;
 Stream postDataStr=authRequest.GetRequestStream();
postDataStr.Write(buffer, 0, buffer.Length);
postDataStr.Close();

现在它已连接到 GSE(Google Servlet 引擎)...我想要对此做出响应....如何实现?

4

1 回答 1

1

您只需要阅读回复:

HttpWebResponse response = (HttpWebResponse)authRequest.GetResponse ();
Console.WriteLine ("Content length is {0}", response.ContentLength);
Console.WriteLine ("Content type is {0}", response.ContentType);
string raw_html = (new StreamReader(response.GetResponseStream()).ReadToEnd();

您可以从以下网址查看更多示例:http: //msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse.aspx

注意:我相信由于您要发布数据,您还必须authRequest通过以下方式将您的设置为 POST:

authRequest.Method = "POST";
于 2013-01-28T05:00:12.027 回答