2 out of 2 rated this helpful - Rate this topic

SiteData.GetSiteUrl Method

Windows SharePoint Services 3
Returns the GUID and URL of the site collection to which the specified URL belongs.

Web Service: Site DataWeb Reference: http://<Site>/_vti_bin/SiteData.asmx
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetSiteUrl", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public uint GetSiteUrl (
	string Url,
	out string siteUrl,
	out string siteId
)

Parameters

Url

siteUrl

siteId

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Difference between SiteData.Url and SiteData.GetSiteUrl

So I looked at this, and I wondered what the difference between SiteData.Url and SiteData.GetSiteUrl is. After testing it, the SiteData.Url is the full URL of the Web Service that you are calling. SiteData.GetSiteUrl is a method that returns the URL of the site collection itself. You can pass any valid URL through this method and it will return the top-level site collection (including any sub web urls, lists, etc).

Example:

C#
//assumes SiteDataWS is the reference to the site data web service
SiteDataWS.SiteData oSite = new SitedataWS.SiteData;
oSite.Credentials = new System.Net.NetworkCredentials("user","password","domain");

SiteDataWS._sSiteMetadata siteMData;
SiteDataWS._sWebWithTime[] subwebs;
string users, groups;
string[] arrGroups;

oSite.GetSite(out siteMData, out subwebs, out users, out groups, out arrGroups);

Response.Write(oSite.Url);//returns the web service URL from the Web Service reference

string outUrl, outSiteID;//the url and Site GUID to be returned by GetUrl
oSite.GetSiteUrl(oSite.Url, out outUrl, out outSiteID);

Response.Write(outUrl);//returns the url of the site that the web service is hosted under