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.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.Invoke( String
methodName, Object[] parameters)
at SPSWebserviceCl ient.preston.Li sts.UpdateListI tems(String listName,
XmlNode updates) in C:\Documents and Settings\Javeed \My Documents\Visua l
Studio Projects\WebPar ts\SPSWebservic eClient\Web
References\pres ton\Reference.c s:line 239
at SPSWebserviceCl ient.clientWind ow.updateList_C lick(Object sender,
EventArgs e) in c:\documents and settings\javeed \my documents\visua l studio
projects\webpar ts\spswebservic eclient\spswebs erviceclient.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.Crede ntials = System.Net.Cred entialCache.Def aultCredentials ;
//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
XmlDocument doc = new System.Xml.XmlD ocument();
XmlElement batchElement = doc.CreateEleme nt("Batch");
batchElement.Se tAttribute("OnE rror","Continue ");
batchElement.Se tAttribute("Lis tVersion","0");
batchElement.Se tAttribute("Vie wName","{D607C0 05-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.In nerXml = "<Method ID='1' Cmd='Update'>"+
"<Field Name='ID'>3</Field>"+
"<Field Name='Position' >100</Field>"+
"</Method>";
// Update list items.
try
{
routeList.Updat eListItems("{B0 81FF04-1604-4F93-BEB2-D71F0EACAADA}",
batchElement);
}
catch(Exception ex)
{
Console.WriteLi ne(ex.StackTrac e);
}
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.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.Invoke( String
methodName, Object[] parameters)
at SPSWebserviceCl ient.preston.Li sts.UpdateListI tems(String listName,
XmlNode updates) in C:\Documents and Settings\Javeed \My Documents\Visua l
Studio Projects\WebPar ts\SPSWebservic eClient\Web
References\pres ton\Reference.c s:line 239
at SPSWebserviceCl ient.clientWind ow.updateList_C lick(Object sender,
EventArgs e) in c:\documents and settings\javeed \my documents\visua l studio
projects\webpar ts\spswebservic eclient\spswebs erviceclient.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.Crede ntials = System.Net.Cred entialCache.Def aultCredentials ;
//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
XmlDocument doc = new System.Xml.XmlD ocument();
XmlElement batchElement = doc.CreateEleme nt("Batch");
batchElement.Se tAttribute("OnE rror","Continue ");
batchElement.Se tAttribute("Lis tVersion","0");
batchElement.Se tAttribute("Vie wName","{D607C0 05-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.In nerXml = "<Method ID='1' Cmd='Update'>"+
"<Field Name='ID'>3</Field>"+
"<Field Name='Position' >100</Field>"+
"</Method>";
// Update list items.
try
{
routeList.Updat eListItems("{B0 81FF04-1604-4F93-BEB2-D71F0EACAADA}",
batchElement);
}
catch(Exception ex)
{
Console.WriteLi ne(ex.StackTrac e);
}