Query Method
The Query method of the List Data Retrieval Service performs queries against lists in Microsoft Windows SharePoint Services.
Parameters
Request A Microsoft.SharePoint.Dsp.QueryRequest object that defines the query.
Return Value
A System.Xml.XmlNode object that contains the query result as follows, which includes a schema section and a data section:
<dsQueryResponse status="success" xmlns="http://schemas.microsoft.com/sharepoint/dsp">
<x:schema xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/XMLSchema">
<x:element name="List_Name">
<x:complexType>
<x:sequence maxOccurs="unbounded">
<x:element name="List_Name_Row" minOccurs="0">
<x:complexType>
<x:sequence>
<x:element name="ID" minOccurs="0"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;Lt;Gt;Leq;Geq;"
d:displayName="ID" type="x:int" />
<x:element name="Title"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;Lt;Gt;Leq;Geq;Contains;BeginsWith;"
d:displayName="Title" type="x:string" />
<x:element name="Modified" minOccurs="0"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;Lt;Gt;Leq;Geq;"
d:displayName="Modified" type="x:dateTime" />
<x:element name="Created" minOccurs="0"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;Lt;Gt;Leq;Geq;"
d:displayName="Created" type="x:dateTime" />
<x:element name="Author" minOccurs="0"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;Lt;Gt;Leq;Geq;"
d:displayName="Created By">
<x:simpleType>
<x:restriction base="x:string">
<x:enumeration value="User_Name" />
</x:restriction>
</x:simpleType>
</x:element>
<x:element name="Editor" minOccurs="0"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;Lt;Gt;Leq;Geq;"
d:displayName="Modified By">
<x:simpleType>
<x:restriction base="x:string">
<x:enumeration value="User_Name" />
</x:restriction>
</x:simpleType>
</x:element>
<x:element name="Attachments" minOccurs="0"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;"
d:displayName="Attachments" type="x:boolean" />
<x:element name="Number_Column" minOccurs="0"
d:filterSupport="IsNull;IsNotNull;Eq;Neq;Lt;Gt;Leq;Geq;"
d:displayName="Number_Column" type="x:float" />
</x:sequence>
</x:complexType>
</x:element>
</x:sequence>
</x:complexType>
</x:element>
</x:schema>
<List_Name xmlns="">
<List_Name_Row>
<ID>1</ID>
<Title>Value</Title>
<Modified>2003-10-01T22:13:57</Modified>
<Created>2003-10-01T22:13:57</Created>
<Author>User_Name</Author>
<Editor>User_Name</Editor>
<Attachments>0</Attachments>
<Number>100</Number>
</List_Name_Row>
<List_Name_Row>
<ID>3</ID>
<Title>Value</Title>
<Modified>2003-10-01T22:14:23</Modified>
<Created>2003-10-01T22:14:23</Created>
<Author>User_Name</Author>
<Editor>User_Name</Editor>
<Attachments>0</Attachments>
<Number>300</Number>
</List_Name_Row>
</List_Name>
</dsQueryResponse>Remarks
Windows SharePoint Services does not support date-time values in XSD format so that time is ignored when using the Query method.
The following table describes properties on the list or site object that is returned.
| Name | Description |
|---|
| comparisonLocale | Optional. Specifies the default Windows locale identifier for a RowReturning object. This attribute is not defined for non-RowReturning objects. |
| contentType | Required. Specifies the content type of the object returned, which is always set to RowReturning for list objects and to TableReturning for site objects. |
| displayName | Optional. Specifies a string containing the friendly name for the list or site object. This property is always returned.
|
| id | Required. A string that identifies the list or site object.
|
| querySupport | Optional. Only the data retrieval service query (DSPQ) is supported.
|
| serverParameters | Required. Always none for list and site objects.
|
| SupportFiltering | Optional. Specifies whether filtering is supported. Always true for RowReturning objects.
Although false for non-RowReturning objects, the unsafe and serverParameters fields can still be filtered.
|
| SupportOrdering | Optional. Specifies whether ordering is supported. Always true.
|
| supportPaging | Optional. The adapter supports forward-only paging as defined in data retrieval service protocol. When paging is requested in the query by specifying startPosition="" within the <dsQuery> element, the adapter will generate an XML BLOB that can be used to retrieve the next batch of rows. This XML BLOB is returned through the next attribute in the <dsQueryResponse> element returned. The client can then set the startPosition attribute to this blob and repeat the original query to retrieve the next set of rows.
|
| unsafe | Optional. Because all site and list objects are safe, this attribute is always set to false.
|
Example
The following code example uses the Query method to return items from a SharePoint list where an Author column contains a specified name and the Number column contains values greater than a specified value.
SOAP Request Format
The following example shows the syntax of a SOAP request made through the data retrieval service. Click a link for information about the element or attribute. The placeholders shown need to be replaced with actual values.
POST /_vti_bin/DspSts.asmx HTTP/1.1
Host: Server_Name
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://schemas.microsoft.com/sharepoint/dsp/queryRequest"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<authentication
xmlns="http://schemas.microsoft.com/sharepoint/dsp">xml</authentication>
<dataRoot
allowRemoteDataAccess="boolean"
xmlns="http://schemas.microsoft.com/sharepoint/dsp">
<root>string</root>
</dataRoot>
<request
document="content or system"
method="query"
xmlns="http://schemas.microsoft.com/sharepoint/dsp" />
<versions xmlns="http://schemas.microsoft.com/sharepoint/dsp">
<version>string</version>
<version>string</version>
</versions>
</soap:Header>
<soap:Body>
<queryRequest
xmlns="http://schemas.microsoft.com/sharepoint/dsp">
<dsQuery
select="string"
resultContent="both or schemaOnly or dataOnly"
columnMapping="element or attribute"
resultNamespace="string"
resultPrefix="string"
resultRoot="string"
resultRow="string"
startPosition="string"
comparisonLocale="string">
<Query
RowLimit="long">
<ServerParameterInfo />
<Fields>
<Field
xsi:nil="true" />
<Field xsi:nil="true" />
<AllFields xsi:nil="true" />
</Fields>
<ServerParameters>
<ServerParameter
xsi:nil="true" />
<ServerParameter xsi:nil="true" />
</ServerParameters>
<Where>xml</Where>
<OrderBy>
<OrderField
xsi:nil="true" />
<OrderField
xsi:nil="true" />
</OrderBy>
</Query>
</dsQuery>
<ptQuery>xml</ptQuery>
</queryRequest>
</soap:Body>
</soap:Envelope>SOAP Response Format
The following example shows the syntax of a SOAP response returned through the data retrieval service. Click an element for information about the data retrieval service element. The placeholders shown need to be replaced with actual values.
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<versions
xmlns="http://schemas.microsoft.com/sharepoint/dsp">
<version>string</version>
<version>string</version>
</versions>
</soap:Header>
<soap:Body>
<queryResponse
xmlns="http://schemas.microsoft.com/sharepoint/dsp">
<xsd:schema>schema</xsd:schema>xml</queryResponse>
</soap:Body>
</soap:Envelope>
Requirements
Platforms: Microsoft Windows Server 2003
Web Reference: http://Server_Name/[sites/][Site_Name/]_vti_bin/DspSts.asmx