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

  • Question



    I've already posted this on the asmx forum, and i'm been suggested to post the problem here. My main problem is that i cannot add web references to my framework 2.0 application, since customers services may change in number with time, so i tried this walkaround. One of the customer has implemented this wcf service (i suppose is wcf since i don't know this technology) which is giving me some problems.

    I'm must contact a remote service using httpwebrequest and response. this service has two method: ping to test the service and another to get the data i need. I'm using the framework 2.0 and xmlspy to create the soap messages and load them later with an xmldocument object. I test the messages with xmlspy and later i test them with c# code. The ping method works correctly in both cases, while i get the response of the second method sending the message with xmlspy but not sending it by code. 

    Supposing xmlspy generates a correct soap message, i must miss something in my code ( see below)


    HttpWebRequest request = (HttpWebRequest)


    ASCIIEncoding encoding = new ASCIIEncoding();

    //i need to pass through a local firewall

    request.Credentials = new NetworkCredential(....);

    request.Proxy = new WebProxy(...);

    request.Method = "POST";

    request.Headers.Add("SOAPAction", "http://...../IB2FleetWCF/GetModuleNotTransfered");//or .../Ping

    request.ContentType = "text/xml; charset=utf-8";

    request.Accept = "text/xml";

    XmlDocument doc = new XmlDocument();

    doc.Load(@"C:\....\GetModuleNotTransfered.xml"); //or .../Ping.xml

    System.IO.StreamWriter stOut = new System.IO.StreamWriter(request.GetRequestStream());





    wresp = (HttpWebResponse)request.GetResponse();

    if (wresp.StatusCode == HttpStatusCode.OK)


    using (Stream s = wresp.GetResponseStream())


    Encoding enc = Encoding.GetEncoding("utf-8");

    readStream = new StreamReader(s, enc);

    result = readStream.ReadToEnd();





    catch (WebException ex)


    StreamReader lettore = new StreamReader(ex.Response.GetResponseStream());

    string valore = lettore.ReadToEnd();




    I'm not a big expert of soap and web services, till now i simply added a web reference to my project and worked with it.

    Could you direct me to some article or tutorial and give me some hints about my problem please?


    thank you in advance



    the value of the response stream is


    <faultcode xmlns:a="">a:ActionNotSupported</faultcode>

      <faultstring xml:lang="en-US">The message with Action 'http://.../GetModuleNotTransfered' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring>
    Thursday, January 3, 2008 2:06 PM

All replies

  • Hello

    to get the detailed error behind  500, no need to check the logs just do the following  :

    1) go to an IE page --> tools> Internet Options> Advanced --> uncheck show friendly http error messages

    2) go to IIS, --> your site --> Features view --> ErrorPages  --> select 500 error --> click Edit feature settings,

        then click detailed errors and click ok

    3) recycle the pool

    4) try to generate the error

     now you will have detailed error

    That's all :)

    Tuesday, May 4, 2010 7:06 PM
  • stefan, were you by any chance resolve this issue? We also do something similar.. create some custom soap request to call the service and get 500 error.
    Thursday, February 17, 2011 4:36 PM
  • If the service you are calling is a WCF service, I would suggest enabling WCF tracing to get more information about the error occuring on the server side. You can find more details on how to configure WCF tracing here:


    Michael Green
    WCF Documentation Team

    Thursday, February 17, 2011 6:41 PM
  • Hi!

    Did you solve this problem already?

    I have the same problem, and it seems that is something related to security (ClientCredentialType and security.mode), that it's not specified directly over the HttpWebRequest.

    Please let us know if you solve it,


    thank you!

    Friday, December 23, 2011 11:39 AM