Showing posts with label Errors. Show all posts
Showing posts with label Errors. Show all posts

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 :)  

Thursday, 12 April 2012

Trying to use an SPWeb object that has been closed or disposed and is no longer valid

I tried to create website which is mostly deals with SharePoint list...   So I planed to minimize the resource usage by using the 'using' statement for the SPSite and SPWeb.

I create SPSite and SPWeb where I need. 

Finally I face the error

Trying to use an SPWeb object that has been closed or disposed and is no longer valid

 I check with the microsoft website

 http://social.technet.microsoft.com/Forums/en/sharepoint2010setup/thread/383931c6-3724-40ff-8ae8-7f26d6db1c92


They suggest don't dispose SPSite or SPWeb including SPContext.SPSite or SPContext.SPWeb also...

I remove the using statement and define the SPSite at the time on initialization by

SPSite MySite= new SPSite(SPContext.Current.WebUrl);

SPWeb MyWeb=null;

  and define the SPWeb in the constructor by 

 MyWeb=MySite.OpenWeb();

 Great now all working fine...

 Happy Coding :)