locked
Interesting Issue - HTTP Error 500 When calling a third party web service from my .NET 4.0 web application, but works from SOAP UI RRS feed

  • Question

  • User102669478 posted

    Hi Everyone,

    I'm working on a web application where I need to call a third party web service to search customer data. This web service is written in Mule API and hosted by a third party team. 

    That team provided me the web service WSDL And end point. I tested the end point in SOAP UI and it works fine. 

    I then added the WSDL as a web reference in my web application and it imported succesffully. However, when I try to call the operation I get the following Error:

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

    That team is saying that the .NET C# code that is calling the web service is not correct. And I'm unsure as to what could be the issue. 

    Any help will be appreciated.

    Regards,

    Nikhil

    Monday, July 18, 2016 3:39 PM

Answers

  • User102669478 posted

    Hi All

    The reason for the error is because the .NET code automatically adds the Expect: 100-continue to the request. When we disabled this header using, System.Net.ServicePointManager.Expect100Continue = false before the service call. It worked fine. 

    Apparently, the Mulesoft proxy couldn't handle this header. 

    Thanks for your all your help.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 1, 2016 7:37 PM

All replies

  • User1289604957 posted

    Hi,

    Please use fiddler http://www.telerik.com/fiddler to give more details.

    Best,

    Maher

    Monday, July 18, 2016 3:53 PM
  • User102669478 posted

    Thanks. I did check with Fiddler and it's interesting. I'm getting back two responses. one with 401 immediately followed with 500. 

    I don't understand why the 401 is coming because I'm passing the credentials as part of the request using the following code:

    serv.Credentials = new System.Net.NetworkCredential(userName:"9d9cfbbfa682447d92e1be9019",
    password:"01c51536b5004e88B40F885DC8F",
    domain:"");

    Am I passing the credentials incorrectly?

    Monday, July 18, 2016 4:11 PM
  • User1289604957 posted

    Hi again,

    Yes, it's a client error. The credentials are not correct.

    Best,

    Maher

    Monday, July 18, 2016 4:55 PM
  • User-474980206 posted

    yes, you are probably passing the credentials correct or you'd get another 401 response from the server. your payload is probably invalid.

    note: the credentials are sent in response to a 401. 

    Monday, July 18, 2016 7:59 PM
  • User102669478 posted

    Hi Maher,

    I don't think the credentials are incorrect. Because, I changed one letter in the password and I got a HTTP 401 error back. Then I changed to the correct password and I get the above 500 error .

    Monday, July 18, 2016 9:20 PM
  • User1869050296 posted

    can you post the rest of the code calling the webservice? is the service hosted under https?

    Tuesday, July 19, 2016 6:08 AM
  • User36583972 posted

    Hi  nikhil.gonsalves,

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

    When the remote server returns an error, then it means that the remote server noticed something bad. When the error is 500, that means it's an internal error, meaning internal to the service - the service threw an exception that was not caught.

    So, you can try the following suggestions.

    1: Look in the Windows event logs on the service to see what went wrong.

    2: Are you sending the proper XML message (SOAP)? If your message isn't formatted properly, you will definitely get a server 500 error back.

    3: You could use the Fiddler. In my experience is the best tools to check what is going on behind the scene.

    4: Invoking Web Service dynamically uses HttpWebRequest :

    http://geekswithblogs.net/marcel/archive/2007/03/26/109886.aspx

    5: Refer the following post solution. May be it will helpful for you.

    ASMX web service and The remote server returned an error: (500) Internal Server Error issue:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/d696d9d8-ef83-4b37-a490-6f69f1712929/asmx-web-service-and-the-remote-server-returned-an-error-500-internal-server-error-issue?forum=wcf

    Best Regards,

    Yohann Lu

    Tuesday, July 19, 2016 6:17 AM
  • User102669478 posted

    Hi All

    The reason for the error is because the .NET code automatically adds the Expect: 100-continue to the request. When we disabled this header using, System.Net.ServicePointManager.Expect100Continue = false before the service call. It worked fine. 

    Apparently, the Mulesoft proxy couldn't handle this header. 

    Thanks for your all your help.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 1, 2016 7:37 PM