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
XMLC#
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=\"http://www.w3.org/2001/XMLSchema-instance\" ";
                  strSoapRequest +=      "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ";
                  strSoapRequest +=      "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" ";
                  strSoapRequest +=      "xmlns=\"http://www.ACORD.org/standards/PC_Surety/ACORD1.10.0/xml/\" ";
                  strSoapRequest +=      ">";
                  strSoapRequest +=      "<soap:Header>";
                  strSoapRequest +=      "<ContractId/> ";
                  strSoapRequest +=      "<AppInfo/> ";
                  strSoapRequest +=      "</soap:Header>";
                  strSoapRequest +=      "<soap:Body>";
                  strSoapRequest +=   InXml;
                  strSoapRequest +=      "</soap:Body>";
                  strSoapRequest +=      "</soap:Envelope>";
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(strSoapRequest);

                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();
                xmlDoc.Save(webStream);
                webStream.Close();
                WebResponse webResponse = webRequest.GetResponse();
                webStream = webResponse.GetResponseStream();

                XmlTextReader xmlReader = new XmlTextReader(webStream);
      //          xmlResponse = new XmlDocument();
                xmlResponse.Load(xmlReader);
                webStream.Close();
            }
            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 = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]

    public class ABCTestWebService :  System.Web.Services.WebService
    {
        [WebMethod]
        public XmlDocumentABCMethod (XmlDocument  InputXML)
        {
         
         }
    }

           
ASKER CERTIFIED SOLUTION
strickdd

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