This is the first article I’m writing on SharePoint technology. I recently had to write custom code to test methods of all the web services applicable in SharePoint online. MSDN does provide description and example for some of web methods. Here I’m aggregating them all to help .NET developers who are looking to get started with SharePoint Web Services.
I assume we all are aware about SharePoint web services but it’s worth reminding you that you can add a web service by right clicking on the solution and adding a web reference. Paste the URL of the web service you wish to call and give it a meaningful name.
Below is the list of web services, their capabilities, method tested and parameters passed to them. If you spot something that should be done in another way please do mention in the comments.
| Alerts | /_vti_bin/alerts.asmx | Provides methods for working with alerts for list items in a SharePoint site. | GetAlerts | A UInt32 that returns 0 to indicate that the operation has completed | No parameters |
| | | | DeleteAlerts | Deletes the specified alerts within a Web site. | IDs
|
Method Name: GetAlerts
protected void btn_Alert_Click(object sender, EventArgs e)
{
Alerts.Alerts AlertServ = new Alerts.Alerts();
AlertServ.Credentials = Mycredentials();
Alerts.AlertInfo AllAllerts = AlertServ.GetAlerts();
lbl_Server.Text = AllAllerts.AlertServerName;
lbl_user.Text = AllAllerts.CurrentUser;
lbl_Managment.Text = AllAllerts.AlertsManagementUrl;
lbl_webtitle.Text = AllAllerts.AlertWebTitle;
}
Method Name: DeleteAlerts
protected void btn_DeleteAlerts_Click(object sender, EventArgs e)
{
Alerts.Alerts AlertServ = new Alerts.Alerts();
AlertServ.Credentials = Mycredentials();
Alerts.AlertInfo AllAllerts = AlertServ.GetAlerts();
txt_DeleteAlerts.Visible = true;
string[] delString = new string[AllAllerts.Alerts.Length];
if (AllAllerts.Alerts.Length > 0)
{ delString[0] = AllAllerts.Alerts[0].Id.ToString(); }
else
{ txt_DeleteAlerts.Text = "There are no alerts"; }
try
{
AlertServ.DeleteAlerts(delString);
txt_DeleteAlerts.Text = "Alerts with id:" + delString + " have been deleted";
}
catch (Exception ex)
{
txt_DeleteAlerts.Text = ex.Message;
}
}
| Copy Web Service | /_vti_bin/Copy.asmx | Provides methods for copying items between locations in the SharePoint environment.
| GetItems | A UInt32 that returns 0 to indicate that the operation has completed | Url,Fields,Stream |
| | | | CopyIntoItemsLocal | Copies a document from one location on a server running Windows SharePoint Services to another location on the same server. | SourceUrl
|
| | | | CopyIntoItems | Copies a document represented by a Byte array to one or more locations on a server. | SourceUrl
|
Method Name: GetItems
protected void btn_GetItemCopy_Click(object sender, EventArgs e)
{
Copy.Copy cp = new Copy.Copy();
cp.Credentials = Mycredentials();
Copy.FieldInformation myFieldInfo = new Copy.FieldInformation();
Copy.FieldInformation[] myFieldInfoArray = { myFieldInfo };
byte[] myByteArray;
UInt32 intItem = cp.GetItem(strUrl,out myFieldInfoArray, out myByteArray);
if (intItem == 0)
{
lbl_GetItemCopy.Text = "Byte array representation of a Fab20SiteTemplate.xls document is generated";
}
else
lbl_GetItemCopy.Text = "OPeration Unsuccessful";
}
Method Name: CopyIntoItemsLocal
protected void btn_CopyIntoItemsLocal_Click(object sender, EventArgs e)
{
Copy.Copy myCopyService = new Copy.Copy();
myCopyService.Credentials = Mycredentials();
string copySource = sourceUrl;
string[] copyDest = { desturl };
Copy.CopyResult myCopyResult1 = new Copy.CopyResult();
Copy.CopyResult myCopyResult2 = new Copy.CopyResult();
Copy.CopyResult[] myCopyResultArray = { myCopyResult1,
myCopyResult2 };
try
{
uint myUint = myCopyService.CopyIntoItemsLocal(copySource,
copyDest, out myCopyResultArray);
if (myUint == 0)
{
int idx = 0;
foreach (Copy.CopyResult myCopyResult in myCopyResultArray)
{
string opString = (idx + 1).ToString();
if (myCopyResultArray[idx].ErrorMessage == null)
{
txt_CopyIntoItemsLocal.Text = "Copy operation " + opString + " completed.\r\n" + "Destination: " + myCopyResultArray[idx].DestinationUrl;
}
else
{
txt_CopyIntoItemsLocal.Text = "Copy operation " + opString + " failed.\r\n" + "Error: " + myCopyResultArray[idx].ErrorMessage + "\r\n" + "Code: " + myCopyResultArray[idx].ErrorCode;
}
idx++;
}
}
}
catch (Exception exc)
{
int idx = 0;
foreach (Copy.CopyResult myCopyResult in myCopyResultArray)
{
idx++;
if (myCopyResult.DestinationUrl == null)
{
string idxString = idx.ToString();
txt_CopyIntoItemsLocal.Text = "Copy operation " + idxString + "failed.\r\n" + myCopyResult.ErrorMessage + myCopyResult.ErrorCode + "Description: " + exc.Message;
}
}
}
}
Method Name: CopyIntoItems
protected void btn_CopyIntoItems_Click(object sender, EventArgs e)
{
Copy.Copy myCopyService = new Copy.Copy();
myCopyService.Credentials = Mycredentials();
string copySource = sourceUrl;
string[] copyDest = { desturl };
Copy.FieldInformation myFieldInfo = new
Copy.FieldInformation();
Copy.FieldInformation[] myFieldInfoArray = { myFieldInfo };
byte[] myByteArray;
uint myGetUint = myCopyService.GetItem(copySource,
out myFieldInfoArray, out myByteArray);
Copy.CopyResult myCopyResult1 = new Copy.CopyResult();
Copy.CopyResult myCopyResult2 = new Copy.CopyResult();
Copy.CopyResult[] myCopyResultArray = { myCopyResult1,
myCopyResult2 };
try
{
uint myCopyUint = myCopyService.CopyIntoItems(copySource, copyDest,
myFieldInfoArray, myByteArray, out myCopyResultArray);
if (myCopyUint == 0)
{
int idx = 0;
foreach (Copy.CopyResult myCopyResult in myCopyResultArray)
{
string opString = (idx + 1).ToString();
if (myCopyResultArray[idx].ErrorMessage == null)
{
txt_CopyIntoItems.Text = "Copy operation " + opString +
"completed.\r\n" + "Destination: " +
myCopyResultArray[idx].DestinationUrl;
}
else
{
txt_CopyIntoItems.Text = "Copy operation " + opString +
" failed.\r\n" + "Error: " +
myCopyResultArray[idx].ErrorMessage + "\r\n" +
"Code: " + myCopyResultArray[idx].ErrorCode;
}
idx++;
}
}
}
catch (Exception exc)
{
int idx = 0;
foreach (Copy.CopyResult myCopyResult in myCopyResultArray)
{
idx++;
if (myCopyResult.DestinationUrl == null)
{
string idxString = idx.ToString();
txt_CopyIntoItems.Text = "Copy operation " + idxString +
" failed.\r\n" + "Description: " + exc.Message;
}
}
}
}
| Document Workspace Web Service | /_vti_bin/DWS.asmx | Provides methods for managing Document Workspace sites and the data they contain. | GetDwsData | returns general information about the Document Workspace site | The site-based URL of a document in a document library |
| | | | CanCreateDwsUrl | Determines whether the user has sufficient rights to create a Document Workspace site with the proposed URL on the server. | proposed URL |
| | | | CreateDws | Creates a Document Workspace site and optionally adds users to the new SharePoint site. | name, users, title, documents |
| | | | CreateFolder | Creates a subfolder in the document library of the current Document Workspace site. | proposed site-based URL |
| | | | DeleteDws | Deletes the current Document Workspace site and its contents. | |
| | | | DeleteFolder | Deletes a subfolder from a document library of the current Document Workspace site. | url |
| | | | FindDwsDoc | Returns the absolute URL of a document | id |
| | | | GetDwsMetaData | Returns information about a Document Workspace site and the lists it contains. | document, id, minimal |
| | | | RemoveDwsUser | Removes the specified user from the list of users for the current Document Workspace site. | user Id |
| | | | RenameDws | Changes the title of the current Document Workspace site. | title |
| | | | UpdateDwsData | Performs a batch update of items and data for the Document Workspace site. | updates, meetingInstance |
Method Name: GetDwsData
protected void btn_DWS_Click(object sender, EventArgs e)
{
txt_DWS.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.GetDwsData("Shared Documents/Fab20SiteTemplate.xls", "");
txt_DWS.Text = strDws.ToString();
}
Method Name: CanCreateDwsUrl
protected void btn_CanCreateDwsUrl_Click(object sender, EventArgs e)
{
txt_CanCreateDwsUrl.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.CanCreateDwsUrl(strUrl);
txt_CanCreateDwsUrl.Text = strDws.ToString();
}
Method Name: CreateDws
protected void btn_CreateDws_Click(object sender, EventArgs e)
{
txt_CreateDws.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string name = "";
string docName = "
string strNewUser = "
try
{
string strDws = dws.CreateDws(name, strNewUser, "TestingCreateDws", docName);
txt_CreateDws.Text = strDws.ToString();
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_CreateDws.Text = ex.Detail.OuterXml;
}
}
Method Name: CreateFolder
protected void btn_CreateFolder_Click(object sender, EventArgs e)
{
txt_CreateFolder.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.CreateFolder("Shared Documents/TestingCreateFolder");
txt_CreateFolder.Text = strDws.ToString();
}
Method Name: DeleteDws
protected void btn_DeleteDws_Click(object sender, EventArgs e)
{
txt_DeleteDws.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.DeleteDws();
txt_DeleteDws.Text = strDws.ToString();
}
Method Name: DeleteFolder
protected void btn_DeleteFolder_Click(object sender, EventArgs e)
{
txt_DeleteFolder.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.DeleteFolder("Shared Documents/TestingCreateFolder");
txt_DeleteFolder.Text = strDws.ToString();
}
Method Name: FindDwsDoc
protected void btn_FindDwsDoc_Click(object sender, EventArgs e)
{
txt_FindDwsDoc.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.FindDwsDoc("034998e9-bf1c-4288-bbbd-00eacfc64410");
txt_FindDwsDoc.Text = strDws.ToString();
}
Method Name: GetDwsMetaData
protected void btn_GetDwsMetaData_Click(object sender, EventArgs e)
{
txt_GetDwsMetaData.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.GetDwsMetaData("Shared Documents/dataview_wp.doc", "", false);
txt_GetDwsMetaData.Text = strDws.ToString();
}
Method Name: RenameDws
protected void btn_RenameDws_Click(object sender, EventArgs e)
{
txt_RenameDws.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.RenameDws("saurabh");
txt_RenameDws.Text = strDws.ToString();
}
Method Name: RemoveDwsUser
protected void btn_RemoveDwsUser_Click(object sender, EventArgs e)
{
txt_RemoveDwsUser.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strDws = dws.RemoveDwsUser("1");
txt_RemoveDwsUser.Text = strDws.ToString();
}
Method Name: UpdateDwsData
protected void btn_UpdateDwsData_Click(object sender, EventArgs e)
{
txt_UpdateDwsData.Visible = true;
DWS.Dws dws = new DWS.Dws();
dws.Credentials = Mycredentials();
string strUpdates = @"
";
string strDws = dws.UpdateDwsData(strUpdates, "");
txt_UpdateDwsData.Text = strDws.ToString();
}
| Imaging Web Service | /_vti_bin/Imaging.asmx | Provides methods that enable you to create and manage picture libraries. | ListPictureLibrary | Microsoft.SharePoint.SoapServer.SoapXml object | No parameters |
| | | | CheckSubwebAndList | Checks the specified URL and attempts to resolve it. | String Url |
| | | | CreateNewFolder | Creates a new folder with the name "New folder" in the specified list and folder | strListName,strParentFolder |
| | | | Delete | Removes the specified files and folders (items) from the specified list on the current Web site. | strListName,strFolderName,itemFileNames |
| | | | Download | Downloads the specified files (items) in a list on the current Web site. | strListName
|
| | | | Edit | Edits the specified files (items) in a list on the current Web site. | strListName
|
| | | | GetItemsByIds | Returns the items with the specified IDs. | strListName
|
| | | | GetItemsXMLData | Returns the metadata of all items in the specified list on the current Web site. | strListName
|
| | | | GetListItems | Returns the last modified date and other information about the items in a specified folder in a list on the current Web site. | strListName
|
| | | | Rename | Renames the specified files (items) in a list on the current Web site. | strListname
|
| | | | Upload | Uploads a file to a list on the current Web site. | strListName,
|
Method Name: ListpictureLibrary
protected void btn_ListpictureLibrary_Click(object sender, EventArgs e)
{
txt_ListpictureLibrary.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
System.Xml.XmlNode node1 = imgServ.ListPictureLibrary();
txt_ListpictureLibrary.Text = node1.InnerXml.ToString();
}
Method Name: CheckSubwebAndList
protected void btn_CheckSubwebAndList_Click(object sender, EventArgs e)
{
txt_CheckSubwebAndList.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
System.Xml.XmlNode node1 = imgServ.CheckSubwebAndList("https://asd.com/Pictures/Forms/AllItems.aspx");
txt_CheckSubwebAndList.Text = node1.OuterXml;
}
Method Name: CreateNewFolder
protected void btn_CreateNewFolder_Click(object sender, EventArgs e)
{
txt_CreateNewFolder.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
try
{
System.Xml.XmlNode node1 = imgServ.CreateNewFolder("Pictures", "");
txt_CreateNewFolder.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_CreateNewFolder.Text = ex.Detail.OuterXml;
}
}
Method Name: Delete
protected void btn_Delete_Click(object sender, EventArgs e)
{
txt_Delete.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
string[] a2=new string[1];
a2[0]="mpd.jpg";
try
{
System.Xml.XmlNode node1 = imgServ.Delete("Pictures", "New Folder", a2);
txt_Delete.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_Delete.Text = ex.Detail.OuterXml;
}
}
Method Name: GetItemsByIds
protected void btn_GetItemsByIds_Click(object sender, EventArgs e)
{
txt_GetItemsByIds.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
uint[] a2=new uint[1];
a2[0]=1;
try
{
System.Xml.XmlNode node1 = imgServ.GetItemsByIds("Pictures", a2);
txt_GetItemsByIds.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetItemsByIds.Text = ex.Detail.OuterXml;
}
}
Method Name: Rename
protected void btn_Rename_Click(object sender, EventArgs e)
{
txt_Rename.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlele = xmlDoc.CreateElement("Fields");
xmlele.InnerXml = "
try
{
System.Xml.XmlNode node1 = imgServ.Rename("Pictures", "New Folder", xmlele);
txt_Rename.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_Rename.Text = ex.Detail.OuterXml;
}
}
Method Name: Upload
protected void btn_Upload_Click(object sender, EventArgs e)
{
txt_Upload.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
Byte[] b =System.Text.Encoding.Unicode.GetBytes("asdasdasdasdasdasdasdas");
try
{
System.Xml.XmlNode node1 = imgServ.Upload("Pictures", "New Folder", b, "saurabh.jpg", true);
txt_Upload.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_Upload.Text = ex.Detail.OuterXml;
}
}
Method Name: Download
protected void btn_Download_Click(object sender, EventArgs e)
{
txt_Download.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
String[] a = new String[1];
a[0]="saurabh.jpg";
System.Xml.XmlNode node1= imgServ.Download("Pictures", "New Folder", a, 0, true);
txt_Download.Text = node1.OuterXml;
}
Method Name: Edit
protected void btn_Edit_Click(object sender, EventArgs e)
{
txt_Edit.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
imgServ.Credentials = Mycredentials();
XmlElement ts=null;
try
{
System.Xml.XmlNode node1 = imgServ.Edit("Pictures", "New Folder", "saurabh.jpg", ts);
txt_Edit.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_Edit.Text = ex.Detail.OuterXml;
}
}
Method Name: GetListItems
protected void btn_GetListItems_Click(object sender, EventArgs e)
{
txt_GetListItems.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
System.Xml.XmlDocument resdoc = new System.Xml.XmlDocument();
System.Xml.XmlNode resnode =resdoc.CreateNode(System.Xml.XmlNodeType.Element, "Result", "");
imgServ.Credentials = Mycredentials();
resnode = imgServ.GetListItems("Pictures", "New Folder");
txt_GetListItems.Text = resnode.OuterXml;
}
Method Name: GetItemsXMLData
protected void btn_GetItemsXMLData_Click(object sender, EventArgs e)
{
txt_GetItemsXMLData.Visible = true;
Imaging.Imaging imgServ = new Imaging.Imaging();
System.Xml.XmlDocument resdoc = new System.Xml.XmlDocument();
System.Xml.XmlNode resnode =resdoc.CreateNode(System.Xml.XmlNodeType.Element, "Result", "");
imgServ.Credentials = Mycredentials();
String[] a = new String[1];
a[0] = "asd.jpg";
imgServ.Url = strUrl;
resnode = imgServ.GetItemsXMLData("Pictures", "Test", a);
txt_GetItemsXMLData.Text = resnode.OuterXml;
}
| Lists Web Service | /_vti_bin/Lists.asmx | Provides methods for working with lists and list data. | GetListItems | returns a schema for the specified list | listName,viewName,query,viewFields,rowLimit,queryOptions |
| | | | AddAttachment | Adds an attachment to the specified list item in the specified list. | listName
|
| Lists Web Service | | | AddDiscussionBoardItem | Adds an item to the specified discussion board on the current Web site. | listName
|
| | | | AddList | Creates a list in the current site based on the specified name, description, and list template ID. | listName
|
| | | | AddListFromFeature | Creates a list in the current site based on the specified name, description, Feature ID, and list template ID. | listName, description, featureID, templateID |
| | | | ApplyContentTypeToList | Adds the specified site content type to a list, as a list content type. | webUrl
|
| | | | CheckInFile | Allows documents to be checked in to a SharePoint document library remotely. | pageUrl
|
| | | | CheckOutFile | Allows documents in a SharePoint document library to be checked out remotely. | pageUrl
|
| Lists Web Service | /_vti_bin/Lists.asmx | Provides methods for working with lists and list data. | CreateContentType | Creates a list content type on the list | listName, displayName, parentType, fields, contentTypeProperties, addToView |
| | | | DeleteAttachment | Removes the attachment from the specified list item. | listName
|
| | | | DeleteContentType | Removes the specified list content type from the designated list. | listName
|
| Lists Web Service | /_vti_bin/Lists.asmx | Provides methods for working with lists and list data. | DeleteContentTypeXmlDocument | Removes the specified XMLDocument element from the specified list content type. | listName
|
| | | | DeleteList | Deletes the specified list. | listName
|
| | | | GetAttachmentCollection | Returns a list of the URLs for attachments to the specified item. | listName
|
| | | | GetList | Returns a schema for the specified list. | listName
|
| | | | GetListAndView | Returns the list and view schemas for the specified list. | listName
|
| | | | GetListCollection | Returns the names and GUIDs for all lists in the site | NA |
| | | | GetListContentType | Returns the content type definition schema for the specified list content type. | listName
|
| | | | GetListItemChanges | Returns changes made to the list since the specified date and time. | listName
|
| | | | GetListItemChangesSinceToken | Returns changes made to the list since the date and time specified in the token. | listName
|
| | | | GetVersionCollection | Returns version information for the specified field in a SharePoint list. | strlistID
|
| | | | UndoCheckOut | Undoes the check-out of a given document in a SharePoint document library. | pageUrl
|
| | | | UpdateContentType | Updates the specified list content type. | listName
|
| | | | UpdateContentTypeXmlDocument | Adds or overwrites the specified XMLDocument element in the specified list content type. | listName
|
| Lists Web Service | /_vti_bin/Lists.asmx | Provides methods for working with lists and list data. | UpdateContentTypesXmlDocument | Adds or overwrites the specified XMLDocument element in the specified list content type. | listName
|
| | | | UpdateList | pdates specified List | listname,listProperties,newFields, updateFields, deleteFields,listVersion |
| | | | UpdateListItems | Adds, deletes, or updates the specified items in a list on the current site. | listName
|
Method Name: GetListItems
protected void btn_GetListItems_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlNode ndQuery = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "Query", "");
System.Xml.XmlNode ndViewFields = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "ViewFields", "");
System.Xml.XmlNode ndQueryOptions = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "QueryOptions", "");
ndQueryOptions.InnerXml = "
"
ndViewFields.InnerXml = "
ndQuery.InnerXml = "
try
{
txt_GetListItems.Visible = true;
System.Xml.XmlNode ndListItems =
list.GetListItems("testlist", null, ndQuery,
ndViewFields, null, ndQueryOptions, null);
txt_GetListItems.Text = ndListItems.OuterXml.ToString();
}
catch
{
}
}
Method Name: AddAttachment
protected void btn_AddAttachment_Click(object sender, EventArgs e)
{
string srcUrl = upload.PostedFile.FileName.ToString();
if (!File.Exists(srcUrl))
{
throw new ArgumentException(String.Format("{0} does not exist",
srcUrl), "srcUrl");
}
FileStream fStream = File.OpenRead(srcUrl);
string fileName = upload.FileName.ToString();
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
string addAttach = list.AddAttachment("testlist", "3", fileName, contents);
txt_AddAttachment.Text = addAttach;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_AddAttachment.Text = "Message:\n" + ex.Message + "\nDetail:\n" + ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace;
}
}
Method Name: AddDiscussionBoardItem
protected void btn_AddDiscussionBoardItem_Click(object sender, EventArgs e)
{
txt_AddDiscussionBoardItem.Visible = true;
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
byte[] b = new byte[100];
try
{
XmlNode node1 = list.AddDiscussionBoardItem("367B9A06-119A-4672-B8CF-0CA4E61E867B", b);
txt_AddDiscussionBoardItem.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_AddDiscussionBoardItem.Text = ex.Detail.OuterXml;
}
}
Method Name: AddList
protected void btn_AddList_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string listname = txt_listname.ToString();
try
{
XmlNode ndList = list.AddList("testinglist123", "Description", 104);
txt_AddList.Text = "Operation Successful";
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_AddList.Text = ex.Detail.OuterXml;
}
}
Method Name: AddListFromFeature
protected void btn_AddListFromFeature_Click(object sender, EventArgs e)
{
txt_AddListFromFeature.Visible = true;
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
Guid featurid=new Guid();
try
{
XmlNode node1 = list.AddListFromFeature("AddListFromFeature", "No Description", featurid, 100);
txt_AddListFromFeature.Text = node1.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_AddListFromFeature.Text = ex.Detail.OuterXml;
}
}
Method Name: ApplyContentTypeToList
protected void btn_ApplyContentTypeToList_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string listname = "testlist";
string webUrl = webUrl;
string contentTypeId = "0x010100D3A967D4FB63AA4BADCAAE4F79CB98D3";
try
{
XmlNode ndList = list.ApplyContentTypeToList(webUrl, contentTypeId, listname);
txt_ApplyContentTypeToList.Text = "Operation Successful";
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_ApplyContentTypeToList.Text = ex.Detail.OuterXml;
}
}
Method Name: CheckInFile
protected void btn_CheckInFile_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string fileCheckin = pageUrl;
try
{
bool myResults = list.CheckInFile(fileCheckin, "Completed revision.", "1");
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_CheckInFile.Text = ex.Detail.OuterXml;
}
}
Method Name: AddAttachment
protected void btn_CheckOutFile_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string fileCheckOut = pageUrl;
try
{
bool myResults = list.CheckOutFile(fileCheckOut, "true", DateTime.Now.ToShortDateString());
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_CheckOutFile.Text = ex.Detail.OuterXml;
}
}
Method Name: CreateContentType
protected void btn_CreateContentType_Click(object sender, EventArgs e)
{
try
{
Webs.Webs web = new Webs.Webs();
web.Credentials = Mycredentials();
string displayName = "myNewContentType";
string parentType = "0x0101";
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlNode newFields = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "FieldRefs", "");
System.Xml.XmlNode contentTypeProperties = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "ContentType", "");
System.Xml.XmlAttribute xmlPropsDesc = xmlDoc.CreateAttribute("Description");
xmlPropsDesc.Value = "New content type description";
contentTypeProperties.Attributes.Append(xmlPropsDesc);
string contentTypeId;
contentTypeId = web.CreateContentType(displayName, parentType, newFields, contentTypeProperties);
lblCreateContentType.Text = contentTypeId;
}
catch (Exception ex)
{
lblCreateContentType.Text = "contentTypeId is already exists";
}
}
Method Name: DeleteAttachment
protected void btn_DeleteAttachment_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
list.DeleteAttachment("testlist", "3", strUrl);
txt_DeleteAttachment.Text = "Operation Successful";
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_DeleteAttachment.Text = ex.Detail.OuterXml;
}
}
Method Name: DeleteContentType
protected void btn_DeleteContentType_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string contentTypeId = "0x010100D3A967D4FB63AA4BADCAAE4F79CB98D300C360AC64AE7EBC4DA8D2C8B4A4C1E301";
try
{
list.DeleteContentType("testlist", contentTypeId);
txt_DeleteContentType.Text = "Operation Successful";
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_DeleteContentType.Text = ex.Detail.OuterXml;
}
}
Method Name: DeleteContentTypeXmlDocumentLST
protected void btn_DeleteContentTypeXmlDocumentLST_Click(object sender, EventArgs e)
{
Lists.Lists lst = new Lists.Lists();
lst.Credentials = Mycredentials();
try
{
System.Xml.XmlNode returnValue = lst.DeleteContentTypeXmlDocument("DeleteContentTypeXmlDocumentLST", "0x0100852A245F10470F4AA9B495FF0D86B2B7", "asd.com/_layouts/ManageContentType.aspx");
txtDeleteContentTypeXmlDocumentLST.Text = returnValue.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txtDeleteContentTypeXmlDocumentLST.Text = ex.Detail.OuterXml;
}
}
Method Name: DeleteList
protected void btn_DeleteList_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
list.DeleteList("deletelist");
txt_DeleteList.Text = "Operation Successful";
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_DeleteList.Text = ex.Detail.OuterXml;
}
}
Method Name: GetAttachmentCollection
protected void btn_GetAttachmentCollection_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
XmlNode ndLists = list.GetAttachmentCollection("testlist", "5");
txt_GetAttachmentCollection.Text = ndLists.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetAttachmentCollection.Text = ex.Detail.OuterXml;
}
}
Method Name: GetList
protected void btn_GetList_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
XmlNode ndLists = list.GetList("testlist");
txt_GetList.Text = ndLists.OuterXml.ToString();
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetList.Text = ex.Detail.OuterXml;
}
}
Method Name: GetListAndView
protected void btn_GetListAndView_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
XmlNode ndLists = list.GetListAndView("testlist", "7AA32316-3B35-462B-873B-2002F8195AC2");
txt_GetListAndView.Text = ndLists.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetListAndView.Text = ex.Detail.OuterXml;
}
}
Method Name: GetListCollection
protected void btn_GetListCollection_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
XmlNode ndLists = list.GetListCollection();
txt_GetListCollection.Text = ndLists.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetListCollection.Text = ex.Detail.OuterXml;
}
}
Method Name: GetListContentType
protected void btn_GetListContentType_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
XmlNode ndLists = list.GetListContentType("testlist", "0x0100D61106F97A2DBC4FB0D19DE3D0357E2F");
txt_GetListContentType.Text = ndLists.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetListContentType.Text = ex.Detail.OuterXml;
}
}
Method Name: GetListItemChanges
protected void btn_GetListItemChanges_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndContains = xmlDoc.CreateNode(XmlNodeType.Element, "Contains", "");
ndViewFields.InnerXml = "
ndContains.InnerXml = "
try
{
XmlNode ndListChanges = list.GetListItemChanges("testlist", ndViewFields, "2003-06-18T00:00:00Z", ndContains);
txt_GetListItemChanges.Text = ndListChanges.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetListItemChanges.Text = ex.Detail.OuterXml;
}
}
Method Name: GetListItemChangesSinceToken
protected void btn_GetListItemChangesSinceToken_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
XmlNode getListName = list.GetList("testlist");
string listName = getListName.Attributes["Name"].Value;
try
{
XmlNode getFirstToken = list.GetListItemChangesSinceToken(listName, null, null, null, null, null, null, null);
txt_GetListItemChangesSinceToken.Text = getFirstToken.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetListItemChangesSinceToken.Text = ex.Detail.OuterXml;
}
}
Method Name: GetVersionCollection
protected void btn_GetVersionCollection_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
XmlNode getListName = list.GetList("testlist");
string listName = getListName.Attributes["ID"].Value;
try
{
XmlNode getFirstToken = list.GetVersionCollection(listName, "1", "status");
txt_GetVersionCollection.Text = "Operation Successful :" + getFirstToken.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_GetVersionCollection.Text = ex.Detail.OuterXml;
}
}
Method Name: UndoCheckOut
protected void btn_UndoCheckOut_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
try
{
bool getFirstToken = list.UndoCheckOut(pageUrl);
txt_UndoCheckOut.Text = "Operation Successful :" + getFirstToken.ToString();
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_UndoCheckOut.Text = ex.Detail.OuterXml;
}
}
Method Name: UpdateContentType
protected void btn_UpdateContentType_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string listName = "testlist";
string contentTypeId = "0x010700B324038CEDF63349B9F2E9EFF5CCD24E";
string ctDescription = "Description";
XmlDocument xmlDoc = new XmlDocument();
XmlNode xmlFields = xmlDoc.CreateNode(XmlNodeType.Element, "Fields", "");
XmlNode xmlProps = xmlDoc.CreateNode(XmlNodeType.Element, "ContentType", "");
XmlAttribute xmlPropsDesc = xmlDoc.CreateAttribute("Description");
xmlPropsDesc.Value = ctDescription;
xmlProps.Attributes.Append(xmlPropsDesc);
XmlNode xmlResult = xmlDoc.CreateNode(XmlNodeType.Element, "Result", "");
try
{
xmlResult.InnerXml = list.UpdateContentType(listName, contentTypeId, xmlProps, xmlFields, xmlFields, xmlFields, "true").OuterXml;
txt_UpdateContentType.Text = "Operation Successful " + xmlResult.InnerXml.ToString();
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_UpdateContentType.Text = ex.Detail.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex1)
{
txt_UpdateContentType.Text = ex1.Detail.OuterXml;
}
}
Method Name: GetListContentType
protected void btn_UpdateContentTypeXmlDocument_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string listName = "testlist";
string contentTypeId = "0x010700B324038CEDF63349B9F2E9EFF5CCD24E";
string ctDescription = "Description";
XmlDocument xmlDoc = new XmlDocument();
XmlNode xmlFields = xmlDoc.CreateNode(XmlNodeType.Element, "Fields", "");
XmlNode xmlProps = xmlDoc.CreateNode(XmlNodeType.Element, "ContentType", "");
XmlAttribute xmlPropsDesc = xmlDoc.CreateAttribute("Description");
xmlPropsDesc.Value = ctDescription;
xmlProps.Attributes.Append(xmlPropsDesc);
XmlNode xmlResult = xmlDoc.CreateNode(XmlNodeType.Element, "Result", "");
try
{
xmlResult.InnerXml = list.UpdateContentTypeXmlDocument(listName, contentTypeId, xmlFields).OuterXml;
txt_UpdateContentTypeXmlDocument.Text = "Operation Successful " + xmlResult.InnerXml.ToString();
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_UpdateContentTypeXmlDocument.Text = ex.Detail.OuterXml;
}
catch (Exception ex1)
{
txt_UpdateContentTypeXmlDocument.Text = ex1.Message.ToString();
}
}
Method Name: UpdateContentTypesXmlDocument
protected void btn_UpdateContentTypesXmlDocument_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string listName = "Contacts";
XmlNode list1 = list.GetList("Contacts");
XmlDocument doc = new XmlDocument();
XmlNode ndProperties = doc.CreateNode(XmlNodeType.Element, "List", "");
XmlAttribute ndTitleAttrib = (XmlAttribute)doc.CreateNode(XmlNodeType.Attribute, "Title", "");
XmlAttribute ndDescription = (XmlAttribute)doc.CreateNode(XmlNodeType.Attribute, "Description", "");
XmlNode ndNewFields = doc.CreateNode(XmlNodeType.Element, "Fields", "");
string listVersion = list1.Attributes["Version"].Value;
ndTitleAttrib.Value = "Contacts";
ndDescription.Value = "My contacts list";
ndProperties.Attributes.Append(ndTitleAttrib);
ndProperties.Attributes.Append(ndDescription);
ndNewFields.InnerXml = "
XmlNode xmlResult = doc.CreateNode(XmlNodeType.Element, "Result", "");
try
{
xmlResult.InnerXml = list.UpdateContentTypesXmlDocument(listName, doc).OuterXml;
txt_UpdateContentTypesXmlDocument.Text = "Operation Successful " + xmlResult.InnerXml.ToString();
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_UpdateContentTypesXmlDocument.Text = ex.Detail.OuterXml;
}
}
Method Name: UpdateList
protected void btn_UpdateList_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndDeleteFields = xmlDoc.CreateNode(XmlNodeType.Element,"Fields", "");
XmlNode ndProperties = xmlDoc.CreateNode(XmlNodeType.Element, "List","");
XmlNode ndNewFields = xmlDoc.CreateNode(XmlNodeType.Element,"Fields", "");
XmlNode ndUpdateFields = xmlDoc.CreateNode(XmlNodeType.Element,"Fields", "");
ndDeleteFields.InnerXml = "
try
{
System.Xml.XmlNode ndListItems =list.UpdateList("61B471ED-8926-46FA-A6B0-91D1C48D5069", null, null, null, ndDeleteFields, "1");
txt_UpdateList.Text = ndListItems.OuterXml.ToString();
}
catch(System.Web.Services.Protocols.SoapException ex)
{
txt_UpdateList.Text = ex.Detail.OuterXml;
}
}
Method Name: UpdateListItems
protected void btn_UpdateListItems_Click(object sender, EventArgs e)
{
Lists.Lists list = new Lists.Lists();
list.Credentials = Mycredentials();
string strBatch = "
"
"
"
"
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.SetAttribute("ListVersion", "1");
elBatch.SetAttribute("ViewName", "7AA32316-3B35-462B-873B-2002F8195AC2");
elBatch.InnerXml = strBatch;
try
{
XmlNode ndReturn = list.UpdateListItems("testlist", elBatch);
txt_UpdateListItems.Text = "Operation Successful " + ndReturn.OuterXml;
}
catch (System.Web.Services.Protocols.SoapException ex)
{
txt_UpdateListItems.Text = ex.Detail.OuterXml;
}
}
No comments:
Post a Comment