Calling Sharepoint 2013 methods as services using WCF

http://sanjivblog.wordpress.com/2010/10/04/get-all-the-item-of-specific-folder-of-document-library-or-list-in-sharepoint-using-c/

http://pankajspoint.blogspot.in/2011/02/iterating-through-sharepoint-document.html

webservice can transfer dataset but not generic lists
where as wcf can transfer both dataset and lists

sp object model cant be accessed in normal appln.sp context will come only if appln is hosted in sp like gmc ,ecg applns.

for accessing sp object model in asp.net web appln u have to expose those sp methods as webservices in sp machine and consume them in the web appln.

host webservice in sharepoint and consuming (2007 sharepoint.using disco command)
—–
http://msdn.microsoft.com/en-us/library/office/ms464040%28v=office.14%29.aspx
http://msmvps.com/blogs/windsor/archive/2011/11/04/walkthrough-creating-a-custom-asp-net-asmx-web-service-in-sharepoint-2010.aspx

sharepoint service network credentials authentication
http://man.ddvip.com/web/bsaspnetapp/LiB0087.html

how to add a new item to sharepoint list programmatically
http://www.mindfiresolutions.com/Add-Update-and-Delete-List-Items-Programmatically-in-Sharepoint-372.php

addding files to doc library
http://www.sharepointblog.in/2013/06/programmatically-addupload-file-to.html
document library
http://blah.winsmarts.com/2009-12-sharepoint_productivity_tip_of_the_day.aspx

http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-create-and-host-wcf-service-inside-sharepoint-2010/

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS

host wcf service in sharepoint and consuming : (select sharpoint 2010 empty project sharepoint template.add service reference and not web reference)
———————————————-
http://mstecharchitect.blogspot.in/2010/03/hosting-wcf-service-inside-sharepoint.html
http://mstecharchitect.blogspot.in/2010/03/calling-wcf-service-hosted-in.html
http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-create-and-host-wcf-service-inside-sharepoint-2010/
authentication : anonymous enabled
error :The HTTP request is unauthorized with client authentication scheme ‘Negotiate’. The authentication header received from the server was ‘NTLM’.
http://jktarun.blogspot.in/2013/03/the-http-request-is-unauthorized-with.html
http://morrisbahrami.blogspot.com.au/2011/02/http-request-is-unauthorized-with.html
http://forums.asp.net/t/1302832.aspx?The+authentication+header+received+from+the+server+was+Negotiate+NTLM+

wcf specified column is added
http://stackoverflow.com/questions/2046206/how-to-prevent-specified-properties-being-generated-in-wcf-clients
————–
Failed to convert key to token – The public key for assembly ‘(null)’ was invalid when running the sn command to know the publickeytoken of an asembly

ERROR: When trying to know the Public key token fo the strong assembly using sn command you may receive an error as below:
Failed to convert key to token — The public key for assembly ‘(null)’ was inval id.

SOLUTION: This error comes because the command options are case sensitive. The option Tp is case sensitive.
C:\Program Files\Microsoft Visual Studio 9.0\VC>sn -Tp \PendingTaskReport.dll

Error : Service Reference Error: Failed to generate code for the service reference
soln: Have to uncheck the Reuse types in all referenced assemblies from Configure service reference option

An unhandled exception of type ‘System.TimeoutException’ occurred in mscorlib.dll

Additional information: The request channel timed out while waiting for a reply after 00:00:59.8750656. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

—-
http://blog.myitechnology.com/2009/06/right-way-to-spwebensureuser.html

if u have people as column in document library or list then u have to insert value there like below (use elevateprivileges)

http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/multiple-user-insertion-in-sharepoint-list/
How to Insert?

Let us suppose, you need to add more than one user at single time in SharePoint List. Users’ values may come from an Active Directory or metadata. All the users are in a string as comma or semicolon separated value. Let us suppose users are in below format.

string usercontrolvalue = “dhananjay,arun,anoj,patra,mub”;

We need to inert these multiple users in a column of type People or Group in SharePoint list.

Step 1

First we need to split name of all the users from the string. Since in our case users are comma separated so below code will make a string array with users as value at different index.

string[] userarray = usercontrolvalue.Split(‘,’);

Step 2

Now we need to convert users as string to SPFieldUserValue. Below function is taking user name as string and converting that into SPFieldUserValue.

_Web variable is denoting current web where List is part of.

public SPFieldUserValue ConvertLoginName(string userid)
{
SPUser requireduser = _web.EnsureUser(userid);
SPFieldUserValue uservalue = new SPFieldUserValue(_web, requireduser.ID, requireduser.LoginName);
return uservalue;
}

Step 3

We need to make instance of SPFieldUserValueCollection

SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();

Step 4

For all the user; we need to convert that as SPFieldUserValue then add that them to SPFieldUserValueCollection instance

for (int i = 0; i < userarray.Length; i++)
{
SPFieldUserValue usertoadd = ConvertLoginName(userarray[i]);
usercollection.Add(usertoadd);
}

Only we need to perform above said task. For your reference entire code as below,

Entire code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
namespace TestingMultipleUsre
{
public partial class _Default : System.Web.UI.Page
{
SPWeb _web;
SPSite _site;
SPList myList
protected void Page_Load(object sender, EventArgs e)
{
string usercontrolvalue = "dhananjay,arun,anoj,patra,mub";
_site = new SPSite("http://adfsaccount:2222/&quot;);
_web = _site.OpenWeb();
myList = _web.Lists["TestingUser"];
_web.AllowUnsafeUpdates = true ;
myList = _web.Lists["TestingUser"];
SPListItem item = myList.Items.Add();
SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();
string[] userarray = usercontrolvalue.Split(',');
for (int i = 0; i cd c:\windows\syswow64\inetsrv

c:\Windows\SysWOW64\inetsrv>appcmd.exe list config -section:system.webServer/ser
verRuntime

c:\Windows\SysWOW64\inetsrv>appcmd.exe set config -section:system.webServer/serv
erRuntime /uploadReadAheadSize:”204800″
Applied configuration changes to section “system.webServer/serverRuntime” for “M
ACHINE/WEBROOT/APPHOST” at configuration commit path “MACHINE/WEBROOT/APPHOST”

———–
in vs command prompt :
at the solution/bin/debug folder type : sn -T “dllname” (for getting strong name) …u will get publickeytoken of that assembly
at the solution/bin/debug foder type : gacutil -i “dllname”(for keeping into gac)
at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI type disco http://skeltadtptest:1111/_vti_bin/final/service.asmx.

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI
c:\Windows\assembly\GAC_msil
c:\windows\assembly

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: