0

I've been battling with this for a number of days and I just can't get to the bottom of it. I have a SharePoint 2010 publishing site and a SharePoint 2016 publishing site. Both on prem, but different farms within the same network. I need pull list data from various lists Pages library, Calendars from 2010 into SharePoint 2016. I need to get value for various publishing fields (images, rich text, calendar event fields, etc). Remember I'm querying a SharePoint 2010 farm from a SharePoint 2016 farm.

So I tried a number of things

  1. SOAP call to the Lists.asmx via JavaScript (added this in a script editor webpart on SP2016 Page - this one doesn't work with Chrome - I get "Failed to load resource: the server responded with a status of 401 (Unauthorized). XMLHttpRequest cannot load _vti_bin/Lists.asmx. Response for preflight has invalid HTTP status code 401". Works partially in IE. The PublishingRollupImage and PublishingImageCaption fields come back as "undefined"

    $(document).ready(function() {
    var soapEnv =
    "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soapenv:Body> \
             <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                <listName>"+listName+"</listName> \
                <viewFields> \
                    <ViewFields> \
                       <FieldRef Name='Title' /> \
                       <FieldRef Name='PublishingRollupImage' /> \
                       <FieldRef Name='PublishingImageCaption' /> \
                   </ViewFields> \
                </viewFields> \
                <rowLimit>9</rowLimit> \
            </GetListItems> \
        </soapenv:Body> \
    </soapenv:Envelope>";
    
    $.ajax({
       url: "https://site.mycompany.com/_vti_bin/Lists.asmx";
       type: "POST",
       dataType: "xml",
       data: soapEnv,
       complete: processResult,
       contentType: "text/xml; charset=\"utf-8\""
    

    }); });

  2. Then I tried the SPServices library - same story as #1.
  3. Then I created a webpart (farm solution on 2016) as per this thread here: https://stackoverflow.com/questions/4791794/client-to-send-soap-request-and-received-response

I get a The remote server returned an error: (401) Unauthorized. from what I read it's got to do with the double hop and NTLM

  1. Also tried using the listdata.svc API via Javascript but can't access publishing fields (images, rich html, etc) values. This one works both in Chrome and IE, but I can only get Title, and a very small set of fields.

I've added the following on the SharePoint 2010 web.config

<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Credentials" value="true" />

Also this

<configuration>
<system.web>
<webServices>
    <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
    </protocols>
</webServices>
</system.web>

Note : both sites are using SSL (https)

I'm at the end of my wits with this. Any help is much appreciated. Thanks

2

To access the SharePoint resources located in remote server you need to use the C# client object model. It is irrespective of version.

You might need to understand the SharePoint 2010 client object model and try samples before start with the actual solution.

If you want to access from JavaScript create your own web service and access from your 2016 site.

  • Thanks! I tried a prototype based on the samples you suggested. First I tried them through a console app running on my SP 2016 dev server and it worked well. However when I embedded that code in a webpart on SP2016 I got The remote server returned an error: (401) Unauthorized. Any clues? – SPBogdan May 5 '17 at 15:52
  • How did you pass credentials? And what is the authentication mode (Classic / Claims) in both versions? – Venkat Konjeti May 5 '17 at 16:55
  • Claims / NTML - the only way I made it work if I actually passed user name, password and domain for a user. Now this is server side code. So I might just use it like this. I tried the JSOM model and for whatever reason the clientContext isn't loading the remote site properly. I'm not gonna fight with it anymore and just use server side code on 2016 using CSOM for now and leave it alone. Thanks for the helpul hint! – SPBogdan May 5 '17 at 18:17
  • 1
    Should I assume this is a case of a double hop issue if claims/ntlm? – SPBogdan May 5 '17 at 18:26
  • Yes. That's the reason. If you have Kerberos set up that will not be the case. – Mike May 5 '17 at 19:13

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.