SoapException -- The expression in the 'select' attribute must select a list ..? - InfoPath Dev
in

InfoPath Dev

SoapException -- The expression in the 'select' attribute must select a list ..?

Last post 08-01-2011 10:43 AM by ThoughtProcess. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-22-2011 11:07 AM

    SoapException -- The expression in the 'select' attribute must select a list ..?

    Hi guys!

     

    I'm trying out another sample from the MSDN documentation, this time on the StsAdapter.Query method.  The full code is available
    here.  My understanding is that "Web_Reference_Folder" and "Web_Reference_Name" should point to the Web References that I imported into my Visual Studio For Applications project.

     

    Web_Reference_Folder.StsAdapter myStsAd = new Web_Reference_Folder.StsAdapter();
    myStsAd.Credentials= System.Net.CredentialCache.DefaultCredentials;
    
    string[] vArray = new string[1];
    vArray[0] = "1.0";
    Web_Reference_Name.Versions myVersion = new Web_Reference_Name.Versions();
    myVersion.version = vArray;
    
    myStsAd.versions = myVersion;
    
    Web_Reference_Name.RequestHeader reqHeader = new Web_Reference_Name.RequestHeader();
    reqHeader.document = Web_Reference_Name.DocumentType.content;
    reqHeader.method = Web_Reference_Name.MethodType.query;
    
    myStsAd.request = reqHeader;
    
    Web_Reference_Name.QueryRequest myRequest = new Web_Reference_Name.QueryRequest();
    
    Web_Reference_Name.DSQuery sQuery = new Web_Reference_Name.DSQuery();
    sQuery.select = "/list[@id='{e5c6603b-0f6c-4bd9-8bb1-57c83854308b}']";    // I changed this to my SharePoint list's GUID
    
    myRequest.dsQuery = sQuery;
    
    Web_Reference_Name.DspQuery spQuery = new Web_Reference_Name.DspQuery();
    XmlDocument xmlDoc = new System.Xml.XmlDocument();
    XmlElement ndQuery = xmlDoc.CreateElement("And");
     
    // I changed this section to query two text columns in my list
    ndQuery.InnerXml = "<Eq><FieldRef Name=\"Author\"/>" +
        "<Value>Name</Value></Eq>" + 
        "<Gt><FieldRef Name=\"Number\"/>" + 
        "<Value>Number</Value></Gt>";
    spQuery.Where = ndQuery;
    
    myRequest.dsQuery.Query = spQuery;
    
    try
    {
        XmlNode myNode = myStsAd.Query(myRequest);
        MessageBox.Show(myNode.OuterXml);
    }
    
    catch (System.Web.Services.Protocols.SoapException ex)
    {
        MessageBox.Show(ex.Message + ex.StackTrace);
    }

     

     

    When I run the code, I get the following exception:

    The expression in the 'select' attribute must select a list.
       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at ThoughtProcessProject.com.myCompany.sharepoint1.StsAdapter.Query(QueryRequest queryRequest) in c:\\projects\\SharePoint\\InfoPath\\ThoughtProcessProject\\Web References\\com.myCompany.sharepoint1\\Reference.cs:line 127
       at ThoughtProcessProject.FormCode.SearchForOldItems(Int32 swVerIdx, Int32 releaseNum) in c:\\projects\\SharePoint\\InfoPath\\ThoughtProcessProject\\FormCode.cs:line 220"

     

    Any ideas?

  • 07-24-2011 01:38 PM In reply to

    Re: SoapException -- The expression in the 'select' attribute must select a list ..?

    Hi ThoughtProcess,

    Just an FYI, we try to respond to 90% of all forum posts. It's not 100% because we can't debug everyone's examples or we wouldn't have time to do real work and earn a meager living. Thank you for your understanding!

    Hopefully, you will hook someone who can easily debug your code. If not, we'd be happy to provide paid support at competitve hourly rates ...

    Patrick Halstead
    Project Manager at Qdabra
  • 08-01-2011 10:43 AM In reply to

    Re: SoapException -- The expression in the 'select' attribute must select a list ..?

    Just for future reference, I didn't have much luck with the StsAdapter problem, but I did have success with the Lists Web Service.

    You can see an example of the code in action on the MSDN page for Lists.GetListItems().  I've pasted the relevant code snippet below:

    Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
    listService.Credentials= System.Net.CredentialCache.DefaultCredentials;
    
    XmlDocument xmlDoc = new System.Xml.XmlDocument();
    
    XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element,"Query","");
    XmlNode ndViewFields = 
        xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields","");
    XmlNode ndQueryOptions = 
        xmlDoc.CreateNode(XmlNodeType.Element,"QueryOptions","");
    
    ndQueryOptions.InnerXml = 
        "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" + 
        "<DateInUtc>TRUE</DateInUtc>";
    ndViewFields.InnerXml = "<FieldRef Name='Field1' />
        <FieldRef Name='Field2'/>";
    ndQuery.InnerXml = "<Where><And><Gt><FieldRef Name='Field1'/>" + 
        "<Value Type='Number'>5000</Value></Gt><Gt><FieldRef Name='Field2'/>" + 
        "<Value Type=
            'DateTime'>2003-07-03T00:00:00</Value></Gt></And></Where>";
    try
    {
        XmlNode ndListItems = 
            listService.GetListItems("List_Name", null, ndQuery, 
            ndViewFields, null, ndQueryOptions, null);
        MessageBox.Show(ndListItems.OuterXml);
    }
    
    catch (System.Web.Services.Protocols.SoapException ex)
    {
        MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" + 
            ex.Detail.InnerText + 
             "\nStackTrace:\n" + ex.StackTrace);
    }

     

    Thanks guys!

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