Friday, 27 July 2012

The request failed with HTTP status 417: Expectation failed when SharePoint calling .asmx web service

I tried to access a web method in a .asmx web service from SharePoint web service.
To add a web reference steps
  1. Add Service Reference
  2. Click Advance button in the window
  3. Click Add Web Reference in the next window
  4. Then paste the asmx path add give a reference name then click ok
After this I tried to call the web method but it gives the  The request failed with HTTP status 417 error  I tried with Google finally I found a link in Code Project
http://www.codeproject.com/Articles/94235/The-request-failed-with-HTTP-status-417-Expectatio

Steps to Resolve
  • We need to have this line of code before making any web requests:  
         System.Net.ServicePointManager.Expect100Continue = false
 
  • Add these lines to the application's configuration file (between <configuration> and </configuration>): 
     
    <system.net>
     <settings>
      <servicePointManager expect100Continue="false" />
     </settings>
    </system.net>
     
     
    Now Everything goes fine.
     
    Happy Coding :)