Groups > Web Hosting > Windows SharePoint Services > Processing Sharepoint GetListItems Web Service using VB6




Processing Sharepoint GetListItems Web Service using VB6

Processing Sharepoint GetListItems Web Service using VB6
Wed, 19 Jul 2006 14:54:17 +000
Hi all, 

I am trying to access list items into a sharepoint site. I get the XML result
but I am puzzled on how to process it to retreive information into an ADODB
recordset. 

Everyway I try it, I get the following error (shown in French in the results): 
ERROR (-2147467259) - Recordset cannot be created. Source XML is incomplete or
invalid. 

My feeling is that it has something to do with the RowsetSchema. 

Here is the code: 


Public Sub ws_Test()

    Dim oSoapClient As MSSOAPLib30.SoapClient30
    Dim oIXMLDOMNodeListResult As MSXML2.IXMLDOMNodeList
    Dim oIXMLDOMNodeListQuery As MSXML2.IXMLDOMNodeList
    Dim oIXMLDOMNodeListViewFields As MSXML2.IXMLDOMNodeList
    Dim vRowLimit As String
    Dim oIXMLDOMNodeListQueryOptions As MSXML2.IXMLDOMNodeList
    Dim oDOMDocumentParameters As New MSXML2.DOMDocument
    Dim oDOMDocumentResult As MSXML2.DOMDocument
    Dim oRecordset As ADODB.Recordset
    Dim oStream As ADODB.Stream
    
    'Open Sharepoint Lists Web Service
    Set oSoapClient =
OpenWebService("http://server/someweb/_vti_bin/Lists.asmx?WSDL")


    'Prepare parameters for GetListItems call
    vRowLimit = ""
    oDOMDocumentParameters.LoadXml ("<Document><Query
/><ViewFields /><QueryOptions /></Document>")
    Set oIXMLDOMNodeListQuery =
oDOMDocumentParameters.getElementsByTagName("Query")
    Set oIXMLDOMNodeListViewFields =
oDOMDocumentParameters.getElementsByTagName("Fields")
    Set oIXMLDOMNodeListQueryOptions =
oDOMDocumentParameters.getElementsByTagName("QueryOptions")
    
    'Getting to the list items
    Set oIXMLDOMNodeListResult = oSoapClient.GetListItems("MyList",
"", oIXMLDOMNodeListQuery, oIXMLDOMNodeListViewFields, vRowLimit,
oIXMLDOMNodeListQueryOptions)

    'Show response
    Debug.Print oIXMLDOMNodeListResult.Item(0).xml

    'First method to generate a recordset
    'Create a DOMDocument from received XML
    Set oDOMDocumentResult = New MSXML2.DOMDocument
    oDOMDocumentResult.LoadXml oIXMLDOMNodeListResult.Item(0).xml
    
    'Create a new recordset and open it with the DOMDocument
    Set oRecordset = New ADODB.Recordset
    On Error Resume Next
    oRecordset.Open oDOMDocumentResult
    Debug.Print "ERROR (" & Err.Number & ") - "
& Err.Description
    On Error GoTo 0
    Set oRecordset = Nothing

    'Second method to generate a recordset
    'Create a new Stream and give it the XML string
    Set oStream = New ADODB.Stream
    oStream.Open
    oStream.WriteText oIXMLDOMNodeListResult.Item(0).xml
    oStream.Position = 0

    'Start with a fresh recordset and open from the Stream
    Set oRecordset = New ADODB.Recordset
    On Error Resume Next
    oRecordset.Open oStream
    Debug.Print "ERROR (" & Err.Number & ") - "
& Err.Description
    On Error GoTo 0
    
    oStream.Close
    Set oStream = Nothing

End Sub


RESULTS

<listitems xmlns="http://schemas.microsoft.com/sharepoint/soap/"
xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema">

<rs:data ItemCount="2">
   <z:row ows_Attachments="0" ows_LinkIssueIDNoMenu="1"
ows_LinkTitle="Problème numéro 1" ows_Status="Actif"
ows_Priority="(2) Normale" ows_Category="(2) Catégorie2"
ows_Title="Problème numéro 1" ows_ID="1"
ows_owshiddenversion="1"/>
   <z:row ows_Attachments="0" ows_LinkIssueIDNoMenu="2"
ows_LinkTitle="problème numéro 2" ows_Status="Actif"
ows_Priority="(2) Normale" ows_Category="(2) Catégorie2"
ows_Title="problème numéro 2" ows_ID="2"
ows_owshiddenversion="1"/>
</rs:data>
</listitems>

ERROR (-2147467259) - L'objet Recordset ne peut pas être créé. Le XML source
est incomplet ou n'est pas valide.
ERROR (-2147467259) - L'objet Recordset ne peut pas être créé. Le XML source
est incomplet ou n'est pas valide.
Post Reply
about | contact