Access Denied - cross web application GetListItems

Jun 8, 2010 at 5:51 PM

I'm trying to go across web applications to retrive list items, which should work. I'm getting an Access Denied but I am the administrator of both sites, and the box admin. So I'm wondering if I'm just missing a parameter.

so my list is on http://test.chop.com and call TopNav. I'm trying to access this from http://test.tomdaly.com. Again this is test code ...

<script src="/_layouts/jquery-1.4.2.js" type="text/javascript"></script>
<script src="/_layouts/jquery.SPServices-0.5.5.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
function getNodes(id, parent, isSubNode)
{
$().SPServices({
    operation: "GetListItems",
    async: false,
    webURL: "http://test.chop.com",
    listName: "TopNav",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Link_x0020_ID' /><FieldRef Name='Link_x0020_Url' /><FieldRef Name='Display' /></ViewFields>",
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='Parent_x0020_ID' /><Value Type='Text'>" + id + "</Value></Eq><Eq><FieldRef Name='Display' /><Value Type='Boolean'>1</Value></Eq></Where><OrderBy><FieldRef Name='Link_x0020_Order' /></OrderBy></Query>",
    completefunc: function (xData, Status) 
	{
		var itemCount = $(xData.responseXML).find("rs\\:data").attr("ItemCount");

		if(isSubNode == "true" && itemCount > 0)
		{
			$("li#"+parent+" a").after("<ul id='"+parent+"'></ul>");
		}
		if(itemCount > 0)
		{
	
			$(xData.responseXML).find("[nodeName=z:row]").each(function()     
			{
				if($(this).attr("ows_Display") != 0)
				{ 
					var linkId = $(this).attr("ows_Link_x0020_ID");
					var linkTitle = $(this).attr("ows_Title");
					var linkUrl = $(this).attr("ows_Link_x0020_Url");
				   
					var html = "<li id='" + linkId + "'><a href='" + linkUrl + "'>" + linkTitle + "</a></li>";
					alert(html);
					if(isSubNode == "true")
					{
					    
						$("li#" + parent + " ul").append(html);
					} 
					else
					{
					   $("#"+parent).append(html);
					}
					getNodes(linkId,linkId,"true");
				} 
			}); 
		}
	}
  });
}



$(document).ready(function() {
getNodes("0000","rootNode");

  });
</script>
<ul id="rootNode"/>
So what I get is actually an error in jquery-1.4.2.js, here on the else statement. and the variables, s.url = http://test.chop.com/_vti_bin/Lists.asmx , s.async = false, type = POST
 // Open the socket
// Passing null username, generates a login popup on Opera (#2865)
if ( s.username ) {
xhr.open(type, s.url, s.async, s.username, s.password);
} else {
xhr.open(type, s.url, s.async);
}

Coordinator
Jun 9, 2010 at 4:15 AM

Tom:

Try stepping past the error (if you need to) and add an alert at the top of the completefunc to see what you're getting back:

alert(xData.responseXML.xml);

Also, even though it probably doesn't have anything to do with the error, I'd change the initial call to:

getNodes("0000","rootNode", false);

And you should change this:

find("rs\\:data")

to

find("[nodeName=rs:data]")

for better cross-broswer compatibility. Check this blog post:
http://mdasblog.wordpress.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/

M.

Jun 9, 2010 at 5:06 AM
i appreciate the quick response, I've made those suggested changes and the normal site still works.
I believe what I'm running into is some cross domain scripting issues. I'm kinda of researching down that way. I'm not able to get past that error. If I do f5 or go through it the page loads and I get the yellow javascript error on on the bottom. So no response back.

Sincerely,

Thomas M. Daly

SharePoint Solutions Developer | B&R Business Solutions, LLC

Microsoft Gold Certified Partner | Specializing in SharePoint-Centric Solutions

Office: (732) 845-5002 x1010 | Cell Phone: (732) 773-5946 | Fax: (732) 845-8145 | tdaly@bandrsolutions.com

http://www.bandrsolutions.com | 315 Route 34, Suite 128, Colts Neck, NJ 07722

Unique Challenges. Innovative Solutions.


From: sympmarc [notifications@codeplex.com]
Sent: Tuesday, June 08, 2010 11:15 PM
To: Tom Daly
Subject: Re: Access Denied - cross web application GetListItems [SPServices:215352]

From: sympmarc

Tom:

Try stepping past the error (if you need to) and add an alert at the top of the completefunc to see what you're getting back:

alert(xData.responseXML.xml);

Also, even though it probably doesn't have anything to do with the error, I'd change the initial call to:

getNodes("0000","rootNode", false);

And you should change this:

find("rs\\:data")

to

find("[nodeName=rs:data]")

for better cross-broswer compatibility. Check this blog post:
http://mdasblog.wordpress.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/

M.

Coordinator
Jun 9, 2010 at 5:10 AM

Hmmm. I'll think on it a bit. I think it should work.

What if you try setting the source list to allow anonymous read?

M.

Jun 9, 2010 at 5:38 AM
Marc,
I've put the list to allow Domain Users acces, still error
I've enable anonymous on the web application for lists and libraries, then enable anonymous on the lists itself, with permission to Add/edit/delete the works, but still getting Access Denied.

td


From: sympmarc [notifications@codeplex.com]
Sent: Wednesday, June 09, 2010 12:10 AM
To: Tom Daly
Subject: Re: Access Denied - cross web application GetListItems [SPServices:215352]

From: sympmarc

Hmmm. I'll think on it a bit. I think it should work.

What if you try setting the source list to allow anonymous read?

M.

Coordinator
Jun 9, 2010 at 5:42 AM

You aren't running a mix of http and SSL are you?  I don't see that in what you've posted above, but I've seen it be a problem in the past.  The only sensible way around it that I've seen is to get a cert for the other domain. (That layer is *not* my forte.)

M.

Jun 9, 2010 at 5:45 AM
No use of HTTPS. Right now in my test environment going from one http site to another http site. Two different web applications completely, however same administrative account and even app pool account running the site.

td


From: sympmarc [notifications@codeplex.com]
Sent: Wednesday, June 09, 2010 12:42 AM
To: Tom Daly
Subject: Re: Access Denied - cross web application GetListItems [SPServices:215352]

From: sympmarc

You aren't running a mix of http and SSL are you? I don't see that in what you've posted above, but I've seen it be a problem in the past. The only sensible way around it that I've seen is to get a cert for the other domain. (That layer is *not* my forte.)

M.

Jun 11, 2010 at 6:30 PM
Marc,
unfortunately I am almost certain that this is cross site scripting, that the webpart of one domain is trying to talk to the web service of another domain.
The jquery web service calls are passing xml and from what i've read that would be blocked.
I've had to change to a coded solution because the webservice calls from one domain to another work fine.
any I will use your project the next time!! thanks for ur help trying to figure this out.
td

From: sympmarc [notifications@codeplex.com]
Sent: Tuesday, June 08, 2010 11:15 PM
To: Tom Daly
Subject: Re: Access Denied - cross web application GetListItems [SPServices:215352]

From: sympmarc

Tom:

Try stepping past the error (if you need to) and add an alert at the top of the completefunc to see what you're getting back:

alert(xData.responseXML.xml);

Also, even though it probably doesn't have anything to do with the error, I'd change the initial call to:

getNodes("0000","rootNode", false);

And you should change this:

find("rs\\:data")

to

find("[nodeName=rs:data]")

for better cross-broswer compatibility. Check this blog post:
http://mdasblog.wordpress.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/

M.

Coordinator
Jun 13, 2010 at 7:39 PM

Tom:

I was afreaid that it might come down to that.  From my perspective, I'm hoping that your experience is atypical, and I believe that it ought to be.  Perhaps it's something specific to your environment.

M.