2

I'm pretty lost here. I've inherited legacy code which uses SOAP to fetch SharePoint content. One method posts a SOAP request against SharePoint to get the HasUniqueRoleAssignments property of list items. Customers claim that this request works with SharePoint 2010 but fails with 2013. I've reproduced the failure with a local 2013 installation. The SharePoint log shows a NullReferenceException

The stack trace looks like this:

Exception occured in scope Microsoft.SharePoint.SPList.GetItems. Exception=System.NullReferenceException: Object reference not set to an instance of an object. 
at Microsoft.SharePoint.ServerStub.SPQueryValueTypeConverter.InitFromXml(Object target, XmlNode parentNode, ProxyContext proxyContext)    

To get a handle on this I've tried a dumbed down SOAP request:

<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="14.0.0.0"
    LibraryVersion="14.0.4762.1000" ApplicationName="Javascript Library">
    <Actions>
        <Query Id="13" ObjectPathId="7">
            <Query SelectAllProperties="true">
                <Properties/>
            </Query>
        </Query>
    </Actions>
    <ObjectPaths>
        <Identity Id="7" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:c90a7dd5-7c70-4bb8-906f-b010a1c5f374:web:1b801818-a0a1-4b97-937c-21367c971bbf:list:71ea27a3-35fc-4573-a6d4-d6adf7a69525"/>
    </ObjectPaths>
</Request>

The Identity references an existing list. The response does return a SP.List with an ItemCount property value of 2. So this looks good. By my (limited) unterstanding I should be able to get the children by specifying a GetItems method and using that in the Query.

So my request looks like this

<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="14.0.0.0"
    LibraryVersion="14.0.4762.1000" ApplicationName="Javascript Library">
    <Actions>
        <Query Id="13" ObjectPathId="10">
            <Query SelectAllProperties="true">
                <Properties/>
            </Query>
        </Query>
    </Actions>
    <ObjectPaths>
        <Identity Id="7" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:c90a7dd5-7c70-4bb8-906f-b010a1c5f374:web:1b801818-a0a1-4b97-937c-21367c971bbf:list:71ea27a3-35fc-4573-a6d4-d6adf7a69525"/>

        <Method Id="10" ParentId="7" Name="GetItems">
            <Parameters>
                <Parameter TypeId="{3d248d7b-fc86-40a3-aa97-02a75d69fb8a}">
                    <Property Name="DatesInUtc" Type="Boolean">true</Property>
                    <Property Name="FolderServerRelativeUrl" Type="Null" />
                    <Property Name="ListItemCollectionPosition" Type="Null" />
                    <Property Name="ViewXml" Type="String">
                        &lt;View Scope="RecursiveAll"&gt;&#xD;
                        &lt;Query&gt;&#xD;
                        &lt;/Query&gt;&#xD;
                        &lt;/View&gt;
                    </Property>
                </Parameter>
            </Parameters>
        </Method>
    </ObjectPaths>
</Request>

This results in an error response with ErrorCode -1 and ErrorMessage "Unknown Error". The corresponding error in the SharePoint logs is the NullReferenceException mentioned above.

My first assumption were the Type="Null" entries but using the corresponding types and values didn't change anything. It seems to fail before trying the query action. I get the same error when I just specify an ObjectPath in the actions section that references the Method ID.

While searching the internet I've found example requests for the GetItems Method. They look exactly like mine. The original Request (and the examples from the internet) contain an additional ChildItemQuery but when I add this I get an Invalid Request error. Is the SharePoint 2013 API different than 2010?

Any ideas are appreciated. Except using the new REST API, that's not option right now.

Stefan

0

I've found the problem. Besides discovering that this request XML has nothing to do with the SOAP API but with the communication of CSOM clients with Sharepoint I've learned that Sharepoint 2013 doesn't like pretty printing in these requests!

The request just works fine if I remove the linebreaks and whitespaces between the tags in the parameters section. Apparently the rest of the XML can be pretty printed. So use a single line for everything between the parameters tags and you're good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.