GetListItems web service performance - InfoPath Dev
in

InfoPath Dev

GetListItems web service performance

Last post 07-27-2007 09:40 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-20-2007 03:34 PM

    GetListItems web service performance

    I'm using the getlistitems webservice to grab data from a sharepoint list and insert the values into a repeating table. It works however it's slower than mollasses if I have over 50 records returned. Does anyone know of a faster way to do what I am doing or if there is a way to use more than 2 filter parameters in the web service? Any help would be greatly appreciated.

    Dim listService As New GETITEMS.Lists

    Dim cr As New System.Net.NetworkCredential("", "", "")

    listService.Credentials = cr

    Dim xmlDoc As New System.Xml.XmlDocument

    Dim listName As String = "{9D39C54C-ABBB-4E79-A3DA-A781ADB09DF3}"

    Dim viewName As String = "{7DC3A6B6-8938-4111-8B6B-CA6F109EA3FB}"

    Dim rowLimit As String = ""

    Dim Unit As String = thisXDocument.DOM.selectSingleNode("//my:myFields/my:ProcessInfo/my:LocationUnit").text

    Dim i As Integer = 1

     

    Dim query As System.Xml.XmlElement = xmlDoc.CreateElement("Query")

    Dim viewFields As System.Xml.XmlElement = xmlDoc.CreateElement("ViewFields")

    Dim queryOptions As System.Xml.XmlElement = xmlDoc.CreateElement("QueryOptions")


    query.InnerXml = "<OrderBy><FieldRef Name=""ActualMaterial"" Ascending=""TRUE""></FieldRef></OrderBy><Where><And>" + _

    "<Neq><FieldRef Name=""Active"" />" + "<Value Type=""Text"">" + "0" + "</Value></Neq>" + _

    "<Eq><FieldRef Name=""Unit"" /><Value Type=""Text"">" + Unit + "</Value></Eq>" + _

    "</And></Where>"

    viewFields.InnerXml = "<FieldRef Name=""TrackingNumber"" /><FieldRef Name=""ActualMaterial"" /><FieldRef Name=""Unit"" /><FieldRef Name=""ContainerType"" /><FieldRef Name=""Size"" /><FieldRef Name=""Weight"" />" + _

    "<FieldRef Name=""ProfileNumber"" /><FieldRef Name=""InboundNumber"" /><FieldRef Name=""ProcessNumber"" /><FieldRef Name=""Material"" /><FieldRef Name=""ID"" /><FieldRef Name=""WeightTicketNumber"" />"

    queryOptions.InnerXml = ""


    Dim
    nodeListItems As System.Xml.XmlNode = listService.GetListItems(listName, viewName, query, viewFields, rowLimit, queryOptions)

    Dim xd As XmlDocument = New XmlDocument

    xd.LoadXml("<?xml version='1.0' ?>" & nodeListItems.OuterXml)

    Dim ns As New XmlNamespaceManager(xd.NameTable)

    ns.AddNamespace("sp", "http://schemas.microsoft.com/sharepoint/soap/")

    ns.AddNamespace("rs", "urn:schemas-microsoft-com:rowset")

    ns.AddNamespace("z", "#RowsetSchema")

    Dim oParentNode As IXMLDOMNode

    oParentNode = thisXDocument.DOM.selectSingleNode("/my:myFields")

    Dim strFields As String

    strFields = "<my:MovementDetail xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-01-15T20-30-41""><my:TrackingNumber/><my:ActualMaterial/><my:Source/><my:ContainerType/><my:Size/><my:MovementWeight/><my:MovementType/><my:MovementTrackingNumber/><my:WasteTrackingID/><my:MovementID/><my:ProfileNumber/><my:InboundNumber/><my:ProcessNumber/><my:Material/><my:MovementLineNumber/><my:WasteTrackingOldID/><my:ShortNumber/><my:WeighTicketNumber/></my:MovementDetail>"

    Dim domXMLNode As IXMLDOMDocument

    domXMLNode = thisXDocument.CreateDOM()

    domXMLNode.async = False

    domXMLNode.loadXML(strFields)

    Dim dataNodes As XmlNodeList = xd.SelectNodes("//sp:listitems/rs:data", ns)

    For Each dataNode As XmlNode In dataNodes

    For Each rowNode As XmlElement In dataNode.ChildNodes

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:TrackingNumber").text = rowNode.Attributes("ows_TrackingNumber").Value

    If rowNode.HasAttribute("ows_ActualMaterial") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:ActualMaterial").text = rowNode.Attributes("ows_ActualMaterial").Value

    End If

    If rowNode.HasAttribute("ows_Unit") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:Source").text = rowNode.Attributes("ows_Unit").Value

    End If

    If rowNode.HasAttribute("ows_ContainerType") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:ContainerType").text = rowNode.Attributes("ows_ContainerType").Value

    End If

    If rowNode.HasAttribute("ows_Size") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:Size").text = rowNode.Attributes("ows_Size").Value

    End If

    If rowNode.HasAttribute("ows_Weight") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:MovementWeight").text = rowNode.Attributes("ows_Weight").Value

    End If

    If rowNode.HasAttribute("ows_ProfileNumber") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:ProfileNumber").text = rowNode.Attributes("ows_ProfileNumber").Value

    End If

    'thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:ProfileNumber").text = rowNode.Attributes("ows_ProfileNumber").Value

    If rowNode.HasAttribute("ows_InboundNumber") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:InboundNumber").text = rowNode.Attributes("ows_InboundNumber").Value

    End If

    'thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:InboundNumber").text = rowNode.Attributes("ows_InboundNumber").Value

    If rowNode.HasAttribute("ows_ProcessNumber") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:ProcessNumber").text = rowNode.Attributes("ows_ProcessNumber").Value

    End If

    'thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:ProcessNumber").text = rowNode.Attributes("ows_ProcessNumber").Value

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:Material").text = rowNode.Attributes("ows_Material").Value

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:ShortNumber").text = rowNode.Attributes("ows_ID").Value

    If rowNode.HasAttribute("ows_WeightTicketNumber") = True Then

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:WeighTicketNumber").text = rowNode.Attributes("ows_WeightTicketNumber").Value

    End If

    'thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:WeighTicketNumber").text = rowNode.Attributes("ows_WeightTicketNumber").Value

    thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & i & "]/my:MovementType").text = CInt(0)

    i = i + 1

    'MsgBox(i, MsgBoxStyle.Critical)

    oParentNode.appendChild(domXMLNode.documentElement.cloneNode(True))

    'thisXDocument.View.ExecuteAction("xCollection::insert", "MovementDetail_74")

    Next

    Next

    Dim last As Integer = thisXDocument.DOM.selectNodes("my:myFields/my:MovementDetail").length

    Dim node As IXMLDOMNode = thisXDocument.DOM.selectSingleNode("/my:myFields/my:MovementDetail[" & last & "]")

    If thisXDocument.DOM.selectSingleNode("//my:myFields/my:MovementDetail[" & last & "]/my:ShortNumber").text = "" And last > 1 Then

    oParentNode.removeChild(node)

    End If

     

    Shaun Nieves
    Sharepoint Manager
  • 07-23-2007 09:30 AM In reply to

    Re: GetListItems web service performance

    Inserting into the main DOM is always slow. A couple things to account for:

    1. Always turn off auto update before doing a lot of insertions. Turn it back on when done.
    2. Watch out for event handlers being fired when you insert into the main DOM. Create a flag variable identifying that you are doing inserts, and telling event handlers (i.e. OnAfterChange) to return if the flag is true.

  • 07-26-2007 01:23 PM In reply to

    Re: GetListItems web service performance

    Thanks for the tip!
    One more question, If I insert into a secondary datasource instead, will that improve performance?
    Shaun Nieves
    Sharepoint Manager
  • 07-27-2007 09:40 AM In reply to

    Re: GetListItems web service performance

    Most definitely. The main DOM has a lot of overhead that secondary DOMs do not have. They are much faster to work with when inserting/deleting.

    While you don't have to worry about autoupdate with a secondary DOM, you should still watch out for any event handlers that might be set up on it and account for that with a flag like I described before.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.