Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

ListSoapClient UpdateListItems error

$
0
0

Hi everybody!

   First of all, thanks for reading...

   I have a WCF service that consume SharePoint Web Service to update list item. It gives me a Microsoft.SharePoint.SoapServer.SoapServerException:

Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown. - System.Collections.ListDictionaryInternal - mscorlib - 
Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Here is my code:

ListsWS.ListsSoapClient lsc = new ListsWS.ListsSoapClient();
                lsc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                lsc.ClientCredentials.Windows.ClientCredential = new NetworkCredential(user, pass, dom);

XElement list = lsc.GetListItems(guidList, null, query, null, null, null, null);

List<XElement> results = list.Descendants().ToList();

XElement updateItem = results[0];
updateItem .SetAttributeValue("ows_DeviceToken", "value to update");

lsc.UpdateListItems(guidList, updateItem);

I've also tried this code:

ListsWS.ListsSoapClient lsc = new ListsWS.ListsSoapClient();
                lsc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                lsc.ClientCredentials.Windows.ClientCredential = new NetworkCredential(user, pass, dom);

XElement list = lsc.GetListItems(guidList, null, query, null, null, null, null);

List<XElement> results = list.Descendants().ToList();

XElement updateItem = results[0];
string strBatch = "<Method ID='1' Cmd='Update'>" +"<Field Name='ID'>1</Field>" +"<Field Name='DeviceToken'>Value to update</Field></Method>";

XElement elBatch = new XElement(strBatch);
elBatch.SetAttributeValue("OnError", "Continue");
lsc.UpdateListItems(list, elBatch);

But gives me this error:

Name cannot begin with the '<' character, hexadecimal value 0x3C. - System.Collections.ListDictionaryInternal - System.Xml -    at System.Xml.XmlConvert.VerifyNCName(String name, ExceptionType exceptionType)
   at System.Xml.Linq.XNamespace.GetName(String localName, Int32 index, Int32 count)
   at System.Xml.Linq.XName.Get(String expandedName)


Thank you very much for your help!

Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>