Hi,
I am trying to update a list on sharepoint server via calling its standard
built in web service. When ever i call the UpdateListitems() method, I get
the following exception:
at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at SPSWebserviceClient.preston.Lists.UpdateListItems( String listName,
XmlNode updates) in C:\Documents and Settings\Javeed\My Documents\Visual
Studio Projects\WebParts\SPSWebserviceClient\Web
References\preston\Reference.cs:line 239
at SPSWebserviceClient.clientWindow.updateList_Click( Object sender,
EventArgs e) in c:\documents and settings\javeed\my documents\visual studio
projects\webparts\spswebserviceclient\spswebservic eclient.cs:line 145
Can any one help me in this. Preston is the name of my server hosting the
sharepoint webservice. Following is my code:
//Creating an instance of a list on the server. Server is "preston" in
this case where the standard SPS web service resides.
preston.Lists routeList = new preston.Lists();
//Authenticating the user by his default credentials.
routeList.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Setting the url to the subsite for which the clients is requesting the
webservice.
routeList.Url =
"http://preston/sites/drmTeamSite/fahadTest/webService/_vti_bin/Lists.asmx";
// Create an XmlDocument object and construct a Batch element and its
attributes.
//The Batch element provides batch processing of commands within HTTP
protocol.
//See
http://msdn.microsoft.com/library/de...SV01027968.asp
XmlDocument doc = new System.Xml.XmlDocument();
XmlElement batchElement = doc.CreateElement("Batch");
batchElement.SetAttribute("OnError","Continue");
batchElement.SetAttribute("ListVersion","0");
batchElement.SetAttribute("ViewName","{D607C005-0AD7-482F-8AF6-7399D252A991}");
/* Specify methods for the batch post using CAML. In each method include
the ID of the item to update and the value to place in the specified
column.*/
batchElement.InnerXml = "<Method ID='1' Cmd='Update'>"+
"<Field Name='ID'>3</Field>"+
"<Field Name='Position'>100</Field>"+
"</Method>";
// Update list items.
try
{
routeList.UpdateListItems("{B081FF04-1604-4F93-BEB2-D71F0EACAADA}",
batchElement);
}
catch(Exception ex)
{
Console.WriteLine(ex.StackTrace);
}