troubleshooting Question

Why am i getting "The remote server returned an error : (500) Internal Server Error" when i consume .net Web Service

Avatar of Kiran_M
Kiran_M asked on
9 Comments1 Solution9619 ViewsLast Modified:
I have .net C# Test Harness consuming a new WebService  I wrote.  I am getting  "The remote server returned an error : (500) Internal Server Error"  when it executes
 WebResponse webResponse = webRequest.GetResponse();

My Test Harness code to invoke Web Service is as follows :

private void CallUsingSOAP(string InXml, out XmlDocument xmlResponse)
              string strSoapRequest = "";
             xmlResponse = null;
      string strABCWebServiceUrl = ConfigurationManager.AppSettings["ABCTestWebServiceURL"];
                  strSoapRequest = "";
                  strSoapRequest +=      "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
                  strSoapRequest +=      "<soap:Envelope ";
                  strSoapRequest +=      "xmlns:xsi=\"\" ";
                  strSoapRequest +=      "xmlns:xsd=\"\" ";
                  strSoapRequest +=      "xmlns:soap=\"\" ";
                  strSoapRequest +=      "xmlns=\"\" ";
                  strSoapRequest +=      ">";
                  strSoapRequest +=      "<soap:Header>";
                  strSoapRequest +=      "<ContractId/> ";
                  strSoapRequest +=      "<AppInfo/> ";
                  strSoapRequest +=      "</soap:Header>";
                  strSoapRequest +=      "<soap:Body>";
                  strSoapRequest +=   InXml;
                  strSoapRequest +=      "</soap:Body>";
                  strSoapRequest +=      "</soap:Envelope>";
                XmlDocument xmlDoc = new XmlDocument();

                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(strABCWebServiceUrl);

                webRequest.Headers.Add("SOAPAction", " ABCMethod");
                //webRequest.Timeout = Int32.Parse("2000");
                webRequest.ContentType = "text/xml; charset=utf-8";
                webRequest.Accept = "text/xml";
                webRequest.Method = "POST";
                Stream webStream = webRequest.GetRequestStream();
                WebResponse webResponse = webRequest.GetResponse();
                webStream = webResponse.GetResponseStream();

                XmlTextReader xmlReader = new XmlTextReader(webStream);
      //          xmlResponse = new XmlDocument();
            catch (Exception e )
                throw new Exception ("" + e.Message);

It throws a exception when it executes the
WebResponse webResponse = webRequest.GetResponse();

The strSoapRequest  is a well formed XML, I checked it it looks ok.

I am not sure why i am getting this error?

My Web Service code is as follows :

namespace ABCTestWebService
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    public class ABCTestWebService :  System.Web.Services.WebService
        public XmlDocumentABCMethod (XmlDocument  InputXML)


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros