1
votes

I am attempting to access a Sharepoint 2007 web service though iOS HTTP calls. The communication protocol is SOAP (1 and 1.2). I am able to successfully execute GetList and GetListAndView. However, when I try GetListItems, I get any number of error messages, none of which make any sense.

The format of the SOAP call (1.2 in this case; but the same issue exists for 1.0) for GetListItems is this:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
        <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <listName>TaskListSample2-0</listName>
            <viewName>{13C5392C-7DBC-4803-A3B8-B377D8566A55}</viewName>
            <query><Query><Where><Or><Eq><FieldRef Name="Title"></FieldRef><Value Type="Text">Test</Value></Eq><IsNotNull><FieldRef Name="Title"></FieldRef></IsNotNull></Or></Where></Query></query>
            <viewFields><ViewFields><FieldRef Name="Title" /><FieldRef Name="Status" /></ViewFields></viewFields>
            <rowLimit>100</rowLimit>
            <queryOptions></queryOptions>
            <webID>c069106a-8d18-43d6-81c2-2687f568a3c5</webID>
        </GetListItems>
    </soap12:Body>
</soap12:Envelope>

The structure of the content between <Query>...</Query> is exactly the same as it is formatted in a a successful .Net call to this function.

I get the following error message back:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <soap:Fault>
            <soap:Code>
                <soap:Value>soap:Receiver</soap:Value>
            </soap:Code>
            <soap:Reason>
                <soap:Text xml:lang="en">Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</soap:Text>
            </soap:Reason>
            <detail>
                <errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Root element is missing.</errorstring>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

I have spent days on this, along with a couple of other programmers who are versed in .Net and Sharepoint. Depending on various editing changes to the query, we have also seen "element &lt;Query&gt; in query is missing or invalid."

I have also, by the way, attempted all of these SOAP calls through Fiddler2 on a Windows box. I see the same exact results as with the iOS HTTP calls.

The closest answer I've been able to get is that the query is formatted incorrectly (duh). But for the life of me, the correct format is eluding us. We have been able to successfully query the server from a native .Net app, but copying the exact content and format of the query XML over to the iOS code changes nothing.

Needless to say, the Microsoft documentation and error messages are criminally useless. And no, we cannot move to MOSS 2010. The client will not be updating any time soon, so we have to work with the technology they have in place.

Any help at all will be incredibly appreciated. Even if someone can definitively demonstrate that that particular web service function is broken for 2007. While it would suck, at least we would know that we aren't totally stupid. But if anyone can identify that I am actually formatting the query wrong and show me how to fix it, that would be amazing.

Thanks.

2

2 Answers

0
votes

I've had some good success using SOAP queries on iOS. It definitely has a nice learning curve. I should note that I'm not an SP-expert, so I can't necessarily explain why yours doesn't work. This was the result of a LOT of googling and (asking on SO). Here's the raw XML when I do a GetListItems:

<?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:Body>
    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>Notes</listName>
      <query>
       <Query>
        <Where>
         <Or>
          <Eq>
            <FieldRef Name="Title"></FieldRef>
            <Value Type="Text">Chris Test</Value>
          </Eq>
          <Eq>
            <FieldRef Name="Folder"></FieldRef>
            <Value Type="Text">Ungrouped</Value>
          </Eq>
         </Or>
        </Where>
       </Query>
      </query>
      <rowLimit>0</rowLimit>
      <queryOptions>
        <QueryOptions xmlns:ns2="http://schemas.microsoft.com/sharepoint/soap/" xmlns="">
          <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
          <ViewAttributes Scope="Recursive" />
        </QueryOptions>
      </queryOptions>
    </GetListItems>
  </soap:Body>
</soap:Envelope>

From a custom list called notes, this would give all entries where a title == Chris Test OR folder == 'Ungrouped'

Edit, I see you have an IsNotNull property, here's how I'm doing that: (trimmed for the sake of brevity)

<query><Query>
  <Where>
    <Or>
      <IsNotNull>
        <FieldRef Name="Title"></FieldRef>
      </IsNotNull>
      <Eq>
        <FieldRef Name="Folder"></FieldRef>
        <Value Type="Text">Ungrouped</Value>
      </Eq>
    </Or>
  </Where>
</Query></query>
0
votes

I know this question is over one year old, but my guess is that you are missing a

<QueryOptions />

element within the

<queryOptions></queryOptions>

node. Hope that helps at least someone :)