locked
The remote server returned an error: (500) Internal Server Error. RRS feed

  • Question

  • User294120459 posted

    I want to call my WebService using HttpWebRequest, but I get Error:The remote server returned an error: (500) Internal Server Error.

    The webservice works fine through the following url:

    http://localhost/ResultsWebServices/FG_Results.asmx?op=Get_FG_Results

    What Do I need to fix?

    namespace ResultsWebservicesConsoleClient
    {
        class FG_Results
        {
            static void Main(string[] args)
            {
                ProcessGetHttpRequest();
            }
    
            private static void ProcessGetHttpRequest()
            {
    
                Uri myUri = new Uri("http://localhost/ResultsWebServices/FG_Results.asmx/SendRequest?CaseNum=FG10-006294");
    
                HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create(myUri);
                HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
                Console.WriteLine();
                if (HttpWResp.StatusCode == HttpStatusCode.OK)
                    Console.WriteLine("\nRequest succeeded and the requested information is in the response  ,Description : {0}", HttpWResp.StatusDescription);
                if (myUri.Equals(HttpWResp.ResponseUri))
                    Console.WriteLine("\nThe Request Uri was not redirected by the server");
                else
                    Console.WriteLine("\nThe Request Uri was redirected to :{0}", HttpWResp.ResponseUri);
                Console.WriteLine("Content length is {0}", HttpWResp.ContentLength);
                Console.WriteLine("Content type is {0}", HttpWResp.ContentType);
                Console.WriteLine("Protocol Version is {0}", HttpWResp.ProtocolVersion.ToString());
    
                // Get the stream associated with the response.
    
                Stream receiveStream = HttpWResp.GetResponseStream();
                // Pipes the stream to a higher level stream reader with the required encoding format.
    
                StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
                Console.WriteLine();
                Console.WriteLine(readStream.ReadToEnd());
                //code there
                HttpWResp.Close();
                readStream.Close();
            }
        }
    }
    




    Monday, August 16, 2010 12:34 PM

Answers

  • User-1178707375 posted

    Try adding the following code to the web.config of the Web Service.

    <webServices>
    <protocols>
    <add name="HttpSoap"/>
    <add name="HttpPost"/>
    <add name="HttpGet"/>
    <add name="Documentation"/>
    <add name="HttpPostLocalhost"/>
    </protocols>
    </webServices>



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 17, 2010 4:21 PM

All replies

  • User1710623990 posted

    can you please post here the exact error message you received in event logs ?


    Tuesday, August 17, 2010 3:26 AM
  • User294120459 posted

    <title>The remote server returned an error: (500) Internal Server Error.</title> <mce:style><!-- body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } --></mce:style><mce:style mce_bogus="1"><!-- body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } --></mce:style><style mce_bogus="1"><!-- body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } --></style>

    Event code: 3005
    Event message: An unhandled exception has occurred.
    Event time: 8/17/2010 1:25:54 PM
    Event time (UTC): 8/17/2010 5:25:54 PM
    Event ID: 6b0dc0352da744cfbebc11a6924b9c50
    Event sequence: 11
    Event occurrence: 2
    Event detail code: 0
     
    Application information:
        Application domain: /LM/W3SVC/1/Root/ResultsWebServices-1-129265390815268332
        Trust level: Full
        Application Virtual Path: /ResultsWebServices
        Application Path: c:\inetpub\wwwroot\ResultsWebServices\
        Machine name: MyMachine
     
    Process information:
        Process ID: 4876
        Process name: w3wp.exe
        Account name: NT AUTHORITY\SYSTEM
     
    Exception information:
        Exception type: InvalidOperationException
        Exception message: Request format is unrecognized for URL unexpectedly ending in '/Get_FG_Results'.
     
    Request information:
        Request URL: http://localhost/ResultsWebServices/FG_Results.asmx/Get_FG_Results?CaseNum=FG10-006294
        Request path: /ResultsWebServices/FG_Results.asmx/Get_FG_Results
        User host address: 127.0.0.1
        User:  
        Is authenticated: False
        Authentication Type:  
        Thread account name: NT AUTHORITY\SYSTEM
     
    Thread information:
        Thread ID: 6
        Thread account name: NT AUTHORITY\SYSTEM
        Is impersonating: False
        Stack trace:    at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
       at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
       at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
       at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
       at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    Tuesday, August 17, 2010 1:22 PM
  • User-1178707375 posted

    Try adding the following code to the web.config of the Web Service.

    <webServices>
    <protocols>
    <add name="HttpSoap"/>
    <add name="HttpPost"/>
    <add name="HttpGet"/>
    <add name="Documentation"/>
    <add name="HttpPostLocalhost"/>
    </protocols>
    </webServices>



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 17, 2010 4:21 PM