0

I developed a basic WCF service in Azure Cloud Service which works perfectly fine. I then wanted to make it a new item on a SharePoint list. The added code works perfectly when I start it from Visual Studio, but does not work when I publish it to Azure. WCF respondes perfectly well if I remove SharePoint related parts so I am not adding the detail of getrecords() function.

public class Service1 : IService1
{
    public List<Test> TestXml()
    {
        string siteUrl = "https://xxxx.sharepoint.com/sites/testsc";

        SecureString passWord = new SecureString();
        foreach (char c in "xxxxxx".ToCharArray()) passWord.AppendChar(c);

        ClientContext clientContext = new ClientContext(siteUrl);
        clientContext.Credentials = new SharePointOnlineCredentials("xxx@xxx.com", passWord);
        SP.List oList = clientContext.Web.Lists.GetByTitle("Test List");

        ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
        ListItem oListItem = oList.AddItem(itemCreateInfo);
        oListItem["Title"] = "My New Item!";

        oListItem.Update();

        clientContext.ExecuteQuery(); 
        return GetRecords();
    }

I reference following libraries if there are of importance

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Security;
using System.Text;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

I wonder if it works fine on the local because the server I run VS also has SharePoint installed on it ? I've added Microsoft.SharePoint references manually to the project.

  • What is the result returned by WCF? – dstarkowski Sep 18 '15 at 10:42
0

Yes, it's possible that works locally because SharePoint installation is installed on your box.

Make sure that SharePoint.Client.* dlls are deployed to Azure. In Solution Explorer open References folder, right click each DLL you've added and select Properties. In Properties window make sure Copy Local value is set to True.

  • Hi dstarkowski, Thanks a lot for your answer, it promptly fixed the issue ! – Charles Sep 18 '15 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.