vipin saini

vipin saini

  • NA
  • 88
  • 0

http post and responce error

Sep 21 2010 4:32 AM

// get the data from the xml document into a byte stream
Byte[] bdata = System.Text.Encoding.UTF8.GetBytes("DS.xml") ;
// instantiate a web client
Label2.Text = bdata.ToString();
System.Net.
WebClient wc = new System.Net.WebClient();
Byte[] bresp;
// add appropriate headers
wc.Headers.Add(
"Content-Type","text/xml");
// send data to server, and wait for a response
bresp = wc.UploadData(
"http://test.ws1-4abc.com/soap/TestWebservice/message", bdata);
// read the response
string resp = System.Text.Encoding.UTF8.GetString(bresp);
XmlDocument xresp = new XmlDocument();
xresp.LoadXml(resp);
// return the xml document response from the server
Label1.Text = xresp.ToString();
i am using this code post xml using http post request but getting the error
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
and the stack trace is
[WebException: The remote server returned an error: (500) Internal Server Error.]
   System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) +302
   System.Net.WebClient.UploadData(Uri address, String method, Byte[] data) +158
   System.Net.WebClient.UploadData(String address, Byte[] data) +34
   Default4.Button1_Click(Object sender, EventArgs e) in c:\Inetpub\vhosts\abc.com\subdomains\des\httpdocs\Default4.aspx.cs:32
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
please tell me the right solution