2
The code is returning the following error message:
An unhandled Exception of type 'System.Net.Webexception' occurred in System.dll
Additional information: Remote server returned an error: (500) Internal Server Error.
Does anyone know the reason for this problem?
private void button1_Click(object sender, EventArgs e)
{
string xmlMessage = "<?xml version=\"1.0\" encoding=\"utf - 8\"?> " +
@"< soap12:Envelope xmlns:xsi = ""http://www.w3.org/2001/XMLSchema-instanc"" xmlns: xsd = ""http://www.w3.org/2001/XMLSchema"" xmlns: soap12 = ""http://www.w3.org/2003/05/soap-envelope"" >"+
@"< soap12:Body > <GetCurrencyByCountry xmlns = ""http://www.webserviceX.NET"" > < CountryName > Brazil </ CountryName >"+
"</ GetCurrencyByCountry > </ soap12:Body ></ soap12:Envelope > ";
string url = "http://www.webservicex.net/country.asmx?op=GetCurrencyByCountry";
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
byte[] requestInFormOfBytes = System.Text.Encoding.ASCII.GetBytes(xmlMessage);
request.Method = "POST";
request.ContentType = "text/xml;charset=utf-8";
request.ContentLength = requestInFormOfBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(requestInFormOfBytes, 0, requestInFormOfBytes.Length);
requestStream.Close();
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
StreamReader respStream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);
string receivedResponse = respStream.ReadToEnd();
MessageBox.Show(receivedResponse);
respStream.Close();
response.Close();
}
You can post the complete exception stack and/or which line error occurs?
– Genos
Yes. The reason is that an error occurred on the server. Does Exception have any more details? Try to see
InnerExceptions
. This webservice was developed by you too?– Jéf Bueno