Search code examples
c#asp.net-mvcsoapwsdl

How to fix 502 Bad Gateway error when calling SOAP webservice in ASP.NET MVC 5?


I am having an issue with an ASP.NET MVC 5 application calling a SOAP web service. I am getting 502 bad gateway error when POSTing to the webservice.

However, when I take the same payload and put it into SOAPUI and POST it to the web service it works fine. We have a ASP.NET Webforms application that calls the same web service without any issue.

Has anyone come across this before?


Solution

  • I have now resolved this. I captured the traffic between SOAPUI and my app in fiddler. The only real difference I found between the requests was that I found that my application was passing Expect: 100-Continue in the headers.

    Adding this piece of code before the POST to the webservice fixed my issue:

    System.Net.ServicePointManager.Expect100Continue = false;