我已经在应用程序引擎中使用java实现了一个现有的应用程序....现在我想从c#forms程序连接这个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 Engine)......我想要对此做出回应....如何实现?
答案 0 :(得分: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";