Thursday, May 5, 2011

Exception of type Microsoft.SharePoint.SoapServer.SoapServerExceptio n was thrown

In this post we will discuss how to resolve the error Exception of type Microsoft.SharePoint.SoapServer.SoapServerExceptio n was thrown which comes in SharePoint 2010.

Also you can check my previous posts on:

- KeywordQuery in SharePoint 2010 Search

- New webparts in SharePoint 2013

- How to use log4net in sharepoint 2010?

I got an error while trying to add user to a group in SharePoint 2010.

Web_Reference.UserGroup userGroup = new Web_Reference.UserGroup();

userGroup.Credentials = System.Net.CredentialCache.DefaultCredentials;

userGroup.Url = @"URL Of the Site/_vti_bin/UserGroup.asmx";

string groupName = "Employees";

string userName = "Bijay";

string userLoginName = "Bijay";

string userEmail = "";

string userNotes = "User Added from Client tool";

userGroup.AddUserToGroup(groupName, userName, userLoginName, userEmail, userNotes);
//same way you can also remove user from the group by using the following object model.
userGroup.RemoveUserFromGroup(groupName, userLoginName);

After executing the error I got the following error

System.Web.Services.Protocols.SoapException: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerExcepti on' was thrown.

But when I updated the strings to the following format that works for me.

string userName = "Bijay Kumar";
string userLoginName = "domain name/sahoobij";
string userEmail = "";

still I am not sure whther it is the right solution or not but I solved the issue.

No comments:

Post a Comment