Note that there are some explanatory texts on larger screens.

plurals
  1. POColdFusion: How to use SharePoint's getListItems()
    primarykey
    data
    text
    <p>Does anybody know how I could get all items from a SharePoint-List?</p> <p>It should be possible to call the function <a href="http://msdn.microsoft.com/en-us/library/ms774532.aspx" rel="nofollow noreferrer">getListItems()</a> with 4 parameters:</p> <ul> <li>One for the list where the information is stored in,</li> <li>the second for the query,</li> <li>the third for the displayed fields, and</li> <li>the fourth that specifies the number of rows to return.</li> </ul> <p>My code is:</p> <pre><code>&lt;cfobject webservice="http://sharepointserver:16999/blog/_vti_bin/SiteData.asmx?wsdl" name="siteDataService" password="pw" username="user" &gt; &lt;cfset siteDataService.GetListItems( "{9BE74555-1150-4AC8-ADE7-EE52923D7CE8}", "&lt;Where&gt;&lt;Lt&gt;&lt;FieldRef Name=""ID"" /&gt;&lt;Value Type=""Counter""&gt;3&lt;/Value&gt;&lt;/Lt&gt;&lt;/Where&gt;", "&lt;FieldRef Name=""ID"" /&gt;&lt;FieldRef Name=""Title"" /&gt;", "4" )&gt; &lt;cfset ServiceResponse = GetSOAPResponse(siteDataService)&gt; &lt;cfdump var="#ServiceResponse#"&gt; </code></pre> <p>But all I get is that error message:</p> <blockquote> <p>Web service operation GetListItems with parameters {{9BE74555-1150-4AC8-ADE7-EE52923D7CE8},3,,4} cannot be found. </p> </blockquote> <p>Normaly you have to pass xmlNodes the the function, like it is told <a href="http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx" rel="nofollow noreferrer">here</a>.</p> <p>I also tried that, but don't know exactly how to make a xmlNode. My code, that also doesn't work is this one:</p> <pre><code>&lt;cfset xmlDoc = XmlNew()&gt; &lt;cfset ndQuery = xmlElemNew(xmlDoc, "Query")&gt; &lt;cfset ndViewFields = xmlElemNew(xmlDoc, "ViewFields")&gt; &lt;cfset ndQueryOptions = xmlElemNew(xmlDoc, "QueryOptions")&gt; &lt;cfset ndQuery = "&lt;Where&gt;&lt;BeginsWith&gt;&lt;FieldRef Name='Name' /&gt;&lt;Value Type='Text'&gt;D&lt;/Value&gt;&lt;/BeginsWith&gt;&lt;/Where&gt;"&gt; &lt;cfset ndViewFields = "&lt;FieldRef Name='ID' /&gt;"&gt; &lt;cfset ndQueryOptions = ""&gt; &lt;cfset listsService.GetListItems( "{52D3A638-FA12-44E8-9C17-5FBCD2899199}", "", ndQuery, ndViewFields, "1", ndQueryOptions, "" )&gt; &lt;cfset ServiceResponse = GetSOAPResponse(listsService)&gt; &lt;cfdump var="#ServiceResponse#"&gt; </code></pre> <p>Is the way I am calling the webservice the right way?</p> <p>Thank you, Kevin</p> <hr> <p>EDIT: Thank you for your answer, I think the XML elements work.</p> <pre><code>&lt;cfset listsService.GetListItems( "{9BE74555-1150-4AC8-ADE7-EE52923D7CE8}", "{1DD69D36-FD18-42B8-B57D-CCA49FD12AFE}", ndQuery.xmlRoot, ndViewFields.xmlRoot, "1", ndQueryOptions.xmlRoot, "" )&gt; </code></pre> <p>But now i get an "Illegal argument exception" (that's great, because it tells me, that the webservice is responding ;) ):</p> <pre> Cannot perform web service invocation GetListItems. The fault returned when invoking the web service operation is: '' java.lang.IllegalArgumentException: java.lang.ClassCastException@f70df9 The error occurred in D:\wwwroot\SharePoint-Tests\blog.cfm: line 83 81 : "1", 82 : ndQueryOptions.xmlRoot, 83 : "" 84 : )> </pre> <p><strong>EDIT 2:</strong></p> <p>This is my new code (April 28)</p> <pre><code> &lt;cfset xmlDoc = XmlNew()&gt; &lt;cfset xmlDoc.xmlRoot = xmlElemNew(xmlDoc, "xmlRoot")&gt; &lt;cfset xmlDoc.xmlRoot.Query = xmlElemNew(xmlDoc, "Query")&gt; &lt;cfset xmlDoc.xmlRoot.ViewFields = xmlElemNew(xmlDoc, "ViewFields")&gt; &lt;cfset xmlDoc.xmlRoot.QueryOptions = xmlElemNew(xmlDoc, "QueryOptions")&gt; &lt;cfset xmlDoc.xmlRoot.Query.XmlChildren[1] = xmlElemNew(xmlDoc, "Where")&gt; &lt;cfset xmlDoc.xmlRoot.Query.where.XmlChildren[1] = xmlElemNew(xmlDoc, "GT")&gt; &lt;cfset xmlDoc.xmlRoot.Query.where.gt.XmlChildren[1] = xmlElemNew(xmlDoc, "Value")&gt; &lt;cfdump var="#xmlDoc#"&gt; &lt;cfset ndQuery = XmlParse("&lt;Query&gt;&lt;Where&gt;&lt;Gt&gt;&lt;FieldRef Name='ID' /&gt;&lt;Value Type='Counter'&gt;0&lt;/Value&gt;&lt;/Gt&gt;&lt;/Where&gt;&lt;/Query&gt;", true)&gt; &lt;cfset ndViewFields = XmlParse("&lt;ViewFields&gt;&lt;FieldRef Name='ID' /&gt;&lt;FieldRef Name='Title' /&gt;&lt;/ViewFields&gt;", True)&gt; &lt;cfset ndQueryOptions = XmlParse("&lt;queryOptions xmlns:SOAPSDK9=""http://schemas.microsoft.com/sharepoint/soap/""&gt;&lt;QueryOptions/&gt;&lt;/queryOptions&gt;", True)&gt; &lt;cfdump var="#ndQuery#"&gt; &lt;cfdump var="#ndViewFields#"&gt; &lt;cfdump var="#ndQueryOptions#"&gt; &lt;cfoutput&gt;#XMLFormat(ndQuery)#&lt;/cfoutput&gt;&lt;br&gt; &lt;cfoutput&gt;#XMLFormat(ndViewFields)#&lt;/cfoutput&gt;&lt;br&gt; &lt;cfoutput&gt;#XMLFormat(ndQueryOptions)#&lt;/cfoutput&gt;&lt;br&gt; &lt;cfinvoke webservice = "#listsService#" method = "GetListItems" returnvariable = "result" timeout = "10" &gt; &lt;cfinvokeargument name="listName" value="{9BE74555-1150-4AC8-ADE7-EE52923D7CE8}"&gt; &lt;cfinvokeargument name="viewName" value=""&gt; &lt;cfinvokeargument name="query" value="#ndQuery.XmlRoot#"&gt; &lt;cfinvokeargument name="viewFields" value="#ndViewFields.XmlRoot#"&gt; &lt;cfinvokeargument name="rowLimit" value="1"&gt; &lt;cfinvokeargument name="queryOptions" value="#ndQueryOptions.XmlRoot#"&gt; &lt;cfinvokeargument name="webID" value="" omit="yes"&gt; &lt;!--- setting "omit" to "yes" will turn the parameter to null ---&gt; &lt;/cfinvoke&gt; &lt;cfdump var="#result#" label="result"&gt; </code></pre> <p>The error message is:</p> <pre><code>Cannot perform web service invocation GetListItems. The fault returned when invoking the web service operation is: java.lang.IllegalArgumentException: argument type mismatch </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload