Help with GetListItem in a Web Service
- From: andres.tellez@xxxxxxxxx
- Date: 17 Oct 2006 21:31:02 -0700
Hi,
I'm creating a Web Service to get an specific Item from a list via
GetListItem. However, the query portion of my GetListItem doesn't seem
to work for some reason. I'm able to get the list node.
Here's my code:
[WebMethod]
public string GetData_Credit(int regDataId)
{
string credit = "";
WebServices.Lists.Lists l = new WebServices.Lists.Lists();
l.Credentials=System.Net.CredentialCache.DefaultCredentials;
XmlDocument xmlDoc = new XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element,"Query","");
XmlNode ndViewFields =
xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields","");
XmlNode ndQueryOptions =
xmlDoc.CreateNode(XmlNodeType.Element,"QueryOptions","");
// ndQuery.InnerXml = "<Query><Where><Eq>" +
// "<FieldRef Name=\"regDataId\" /><Value
Type=\"String\">1</Value></Eq></Where></Query>";
ndViewFields.InnerXml = "<FieldRef Name=\"credit\" />";
ndQueryOptions.InnerXml = "";
XmlNode nodeListItems = null;
try
{
nodeListItems = l.GetListItems("ListName", null, ndQuery,
ndViewFields, null, null);
credit = nodeListItems.OuterXml.ToString();
}
catch(SoapException e)
{
credit = e.Message;
String error=e.Detail.OuterXml;
}
finally
{
if ( l != null )
{
l.Dispose();
l = null;
}
}
return credit;
}
Please notice how I commented ndQuery. This WebMethod works the same
with or without ndQuery. Again, my question is: Why is ndQuery not
working? Have I forgotten something?
By the way, I have checked this CAML query in various tools in the web
and the ndQuery is written correctly (ort at least it worked in the
CAML tools). I would appreciate any help provided. Thanks!
.
- Follow-Ups:
- Re: Help with GetListItem in a Web Service
- From: andres . tellez
- Re: Help with GetListItem in a Web Service
- Prev by Date: Learning CAML
- Next by Date: Re: Help with GetListItem in a Web Service
- Previous by thread: Learning CAML
- Next by thread: Re: Help with GetListItem in a Web Service
- Index(es):