Posts

Showing posts from July, 2015

Using Sharepoint objects (SPSite| SPWeb) in Sharepoint Hosted WCF service

Recently I Implemented and hosted WCF service inside Sharepoint (_vti_bin folder). so when I try to consume list and other sharepoint related object I got some SPSecurity errors. so normally what we do is something like below  using  ( SPSite  site =  new   SPSite (ProjectInfo.SiteUrl)) { // Your code here } but this approche will give you an error (SPSecurity is unhandled by user code). so to overcome that issue you can use  SPUserToken. SystemAccount when you try to creae a SPSite object or SPWeb object.   using ( SPSite site = new SPSite (ProjectInfo.SiteUrl, SPUserToken .SystemAccount )) { // Your code here } Note : And also use SPSecurity.RunwithElevatedPrivileges  to execute specified method with full control rights even if the current user doesn't have full control.

Deploy and Consume Sharepoint 2010 hosted WCF Service - Part 2

Image
Welcome back, I talked about how to create a HTTPS enable Sharepoint site in the 1st Part of this post series. You can find it here . 1. Create SharePoint WCF in Visual Studio 2010 1.1 Go to Visual studio Go to new project and Select empty Sharepoint 2010 Project. 1.2  Then it will ask you to select a Sharepoint site which you wanna host this Sharepoint Project. so give your Sharepoint site and Check on Deploy as Farm Solution 1.3 Now it's time to add your WCF  component  to your project. by default you cannot directly add a WCF component to your project. so Here I'm going to use CKS Dev component to do that.  1.4 Go to menu bar and select tool. then select on Extenstion manager to Add CKS Dev tool. Search for CKS Dev on online Gallery and Install CKS Dev server component. 1.5 Once you install CKS dev re-start your Visual studio and now you can add WCF components to your solution easily. Select your Project and select on add new Item and select WCF serv...

Deploy and Consume Sharepoint 2010 hosted WCF Service - Part 1

Image
Hosting a WCF service inside Sharepoint is now pretty easy and consume those services are also pretty easy compare with sharepoint. Today I'm going to create a simple SOAP WCF service and I'm going to host it inside Sharepoint Site. ( Note - HTTPS is enable in this Sharepoint site and It uses Claim base authentication) 1. Create HTTPS Sharepoint Web Application and Site Collection. 1.1 Go to Share Point  Central Administration  site and select Application Management  1.2  Select Manage Web application, It will redirect you to Web Application page. From thre select New button to create a new Site. Then Sharepoint will popup a window to create a new Web Application. Here I'm going to keep the most of the settings as it is but i'm going to change following settings Note - Change Authenitication to "Claims Based Authentication" In Authentication section and Select "Yes" for Use Secure Socket Layer in Security Section. Then Press OK to continue...