I am working on SOAP requests, getting error again & again
"The remote server returned an error: (500) Internal Server Error" at
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
SOAP URL is configured in public IP.
Below is my code.
void testing()
{
string webURL = "http://IP address/momapitest/ServiceClients/OperationClient.svc";
string xml = "
string url = webURL;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(xml);
req.Method = "POST";
req.ContentType = "text/xml; charset=\"utf-8\"";
Stream requestStream = null;
try
{
req.ContentLength = requestBytes.Length;
requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
}
catch (WebException ex)
{
}
finally
{
if (requestStream != null)
{
requestStream.Close();
}
}
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();
sr.Close();
res.Close();
XmlDocument xmlDocBooks = new XmlDocument();
XmlDocument doc = new XmlDocument();
doc.InnerXml = backstr;
}
Vithal WadjePosted Feb 26, 2015, 11:11 AM