B
Brian
I'm trying to do a POST using the following code, but I'm getting a
500 error. Can somebody please help me? I'm been stuck for quite a
while.
private void bnInvoke_Click(object sender, System.EventArgs e)
{
string lcUrl = "http://www.xmlwebservices.cc/ws/v1/calc/SimpleCalc.asmx/Add";
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
// *** Send any POST data
string lcPostData = "a=" + HttpUtility.UrlEncode("4") + "&b=" +
HttpUtility.UrlEncode("5") ;
loHttp.Method="POST";
byte [] lbPostBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();
HttpWebResponse loWebResponse = (HttpWebResponse)
loHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(loWebResponse.GetResponseStream(),enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
tbResult.Text = lcHtml;
}
500 error. Can somebody please help me? I'm been stuck for quite a
while.
private void bnInvoke_Click(object sender, System.EventArgs e)
{
string lcUrl = "http://www.xmlwebservices.cc/ws/v1/calc/SimpleCalc.asmx/Add";
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
// *** Send any POST data
string lcPostData = "a=" + HttpUtility.UrlEncode("4") + "&b=" +
HttpUtility.UrlEncode("5") ;
loHttp.Method="POST";
byte [] lbPostBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();
HttpWebResponse loWebResponse = (HttpWebResponse)
loHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(loWebResponse.GetResponseStream(),enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
tbResult.Text = lcHtml;
}