Hi All,
I have two web services, where first application receives a request and
sends the request to the second web service. Based on the response
received from second application, the first application, responds to
the client.
It works fine for the normal cases. But when i wanted to check the
error messages, it the client application receives Error 404. But when
the same error is returned from the second application using "return "
statement, the client receives it as "The remote server returned an
error: (500) Internal Server Error."
Both the first app and client use similar codes, but why the second
application receives it with Error code 500?
Here is the code,
try
{
string strg = envelope.InnerXml;
req.Method = "POST";
req.KeepAlive = true;
req.ContentType = "text/xml";
byte[] bytes =
System.Text.Encoding.UTF8.GetBytes(strg);
req.ContentLength = bytes.Length;
req.Headers.Add("SOAPAction: mySoapAction");
System.IO.Stream st = req.GetRequestStream();
st.Write(bytes, 0, bytes.Length);
st.Close();
HttpWebResponse res =
(HttpWebResponse)req.GetResponse();
System.IO.Stream st1 = res.GetResponseStream();
System.IO.StreamReader sr = new
System.IO.StreamReader(st1, System.Text.Encoding.UTF8);
string txt = sr.ReadToEnd();
SoapEnvelope response = new SoapEnvelope();
response.LoadXml(txt);
//this.txtSOAPResponse.Text = txt;
res.Close();
Console.WriteLine(response.Envelope.OuterXml);
return true;
}
catch (WebException exp)
{
Console.WriteLine(exp.Message);
Console.WriteLine(exp.StackTrace);
return false;
}
catch (Exception exp)
{
Console.WriteLine(exp.Message);
Console.WriteLine(exp.StackTrace);
return false;
}
Any help?