: AreaService (Clase) (Microsoft.SharePoint.Portal)
Obsolete. Provides an area interface for remote clients.
Espacio de nombres:
Ensamblado: Microsoft.SharePoint.Portal (in microsoft.sharepoint.portal.dll)
Sintaxis
'Declaración
<WebServiceAttribute(Namespace:="https://microsoft.com/webservices/SharePointPortalServer/WebQueryService/", Description:="Office SharePoint Server Area Service")> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel:=True)> _
Public Class AreaService
Inherits WebService
'Uso
Dim instance As AreaService
[WebServiceAttribute(Namespace="https://microsoft.com/webservices/SharePointPortalServer/WebQueryService/", Description="Office SharePoint Server Area Service")]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)]
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel=true)]
public class AreaService : WebService
Comentarios
The Area Service is available on any Web server running Windows Server 2003. To create an AreaWebService proxy:
In Visual Studio 2005, right click on the references folder for the new WebService project.
In the URL type the server URL (typically
https://server
) plus/_vti_bin/AreaService.asmx
(this is the path to the file that describes the Web service).Click Go
After Visual Studio 2005 discovers the Web service, enter AreaWebService in the Web reference name box.
Ejemplo
The following code example shows the use of the Area Service Web service.
using System;
using System.Net;
using AreaServiceExample;
namespace AreaServiceExample
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class AreaServiceExample
{
private const string k_strAreaServicePath = "/_vti_bin/AreaService.asmx";
public string m_strServerUrl;
public string m_strUsername;
public string m_strPassword;
public string m_strDomain;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
AreaServiceExample example = new AreaServiceExample();
if (0 == args.Length)
return;
// store the area service path
example.m_strServerUrl = args[0];
// sort through the params
string strMethod = String.Empty;
string strTitle = String.Empty;
string strDescription = String.Empty;
string strExternalUrl = String.Empty;
foreach (string strArg in args)
{
if (strArg.ToLower().StartsWith("/user:"))
{
example.m_strUsername = strArg.Substring(6);
}
else if(strArg.ToLower().StartsWith("/pass:"))
{
example.m_strPassword = strArg.Substring(6);
}
else if(strArg.ToLower().StartsWith("/domain:"))
{
example.m_strDomain = strArg.Substring(8);
}
else if(strArg.ToLower().StartsWith("/method:"))
{
strMethod = strArg.Substring(8).ToLower();
}
else if(strArg.ToLower().StartsWith("/title:"))
{
strTitle = strArg.Substring(7);
}
else if(strArg.ToLower().StartsWith("/descr:"))
{
strDescription = strArg.Substring(7);
}
else if(strArg.ToLower().StartsWith("/exturl:"))
{
strExternalUrl = strArg.Substring(8);
}
}
// what method did they want us to use?
switch (strMethod)
{
case "createtopicarea":
example.CreateTopicArea(strTitle);
break;
case "deletetopicarea":
example.DeleteTopicArea(strTitle);
break;
case "createtopiclisting":
example.CreateTopicListing(strTitle, strDescription, strExternalUrl);
break;
case "deletetopiclisting":
example.DeleteTopicListing(strTitle);
break;
default:
return;
}
}
/// <summary>
/// Create an area in the "Topics" area
/// </summary>
/// <param name="strTopicTitle"></param>
private void CreateTopicArea(string strTopicTitle)
{
// create the area service object
AreaWebService.AreaService areaService = CreateAreaService();
// get the guid of the "Topics" Area so we can create our
// own Area in there
Guid guidTopics = areaService.GetTopicsAreaID();
// template names are found at (insert correct path)
Guid guidNewArea = areaService.CreateArea(guidTopics, strTopicTitle, "SPSTopic");
// log the creation time
AreaWebService.AreaData areaData = areaService.GetAreaData(guidNewArea);
Console.WriteLine(String.Format("Area {0} created at {1}",
areaData.AreaName,
areaData.CreationDate.ToString()));
}
/// <summary>
/// Delete a "Topics" area by looping through all its sub-areas
/// </summary>
/// <param name="strTopicTitle"></param>
private void DeleteTopicArea(string strTopicTitle)
{
// create the area service object
AreaWebService.AreaService areaService = CreateAreaService();
// get the guid of the "Topics" Area so we can create our
// own Area in there
Guid guidTopics = areaService.GetTopicsAreaID();
bool fFoundArea = false;
Guid[] topicAreaGuids = areaService.GetSubAreas(guidTopics);
foreach (Guid areaGuid in topicAreaGuids)
{
AreaWebService.AreaData areaData = areaService.GetAreaData(areaGuid);
if (strTopicTitle.ToLower() == areaData.AreaName.ToLower())
{
areaService.DeleteArea(areaGuid);
fFoundArea = true;
break;
}
}
if (!fFoundArea)
throw new ArgumentException("Unable to find specified area", "strTopicTitle");
}
/// <summary>
/// Create a listing in the "Topics" area
/// </summary>
/// <param name="strListingTitle"></param>
/// <param name="strDescription"></param>
/// <param name="strExternalUrl"></param>
private void CreateTopicListing(string strListingTitle, string strDescription, string strExternalUrl)
{
// create the area service object
AreaWebService.AreaService areaService = CreateAreaService();
// get the guid of the "Topics" Area so we can create our
// own Area in there
Guid guidTopics = areaService.GetTopicsAreaID();
// template names are found at (insert correct path)
Guid guidNewListing = areaService.CreateAreaListing(guidTopics,
strListingTitle,
strDescription,
AreaWebService.ListingType.ExternalUrl,
strExternalUrl);
// log the creation time
AreaWebService.AreaListingData listingData = areaService.GetAreaListingData(guidNewListing);
Console.WriteLine(String.Format("AreaListing {0} created at {1}",
listingData.Title,
listingData.CreationDate.ToString()));
}
/// <summary>
/// Delete a "Topics" listing by looping through all its sub-listings
/// </summary>
/// <param name="strListingTitle"></param>
private void DeleteTopicListing(string strListingTitle)
{
// create the area service object
AreaWebService.AreaService areaService = CreateAreaService();
// get the guid of the "Topics" Area so we can create our
// own Area in there
Guid guidTopics = areaService.GetTopicsAreaID();
bool fFoundListing = false;
Guid[] topicListingGuids = areaService.GetAreaListings(guidTopics);
foreach (Guid listingGuid in topicListingGuids)
{
AreaWebService.AreaListingData listingData = areaService.GetAreaListingData(listingGuid);
if (strListingTitle.ToLower() == listingData.Title.ToLower())
{
areaService.DeleteAreaListing(listingGuid);
fFoundListing = true;
break;
}
}
if (!fFoundListing)
throw new ArgumentException("Unable to find specified listing", "strTopicTitle");
}
/// <summary>
/// Create the area service proxy object and pre-populate it's properties
/// </summary>
/// <returns></returns>
private AreaWebService.AreaService CreateAreaService()
{
AreaWebService.AreaService areaService = new AreaWebService.AreaService();
areaService.PreAuthenticate = true;
areaService.AllowAutoRedirect = true;
areaService.Url = m_strServerUrl + k_strAreaServicePath;
if ((0 != m_strUsername.Length) && (0 != m_strPassword.Length))
{
NetworkCredential credential = new NetworkCredential(m_strUsername, m_strPassword, m_strDomain);
CredentialCache cc = new CredentialCache();
cc.Add(new Uri(m_strServerUrl), "NTLM", credential);
//cc.Add(new Uri(m_strServerUrl), "Basic", credential);
// set our network credentials
areaService.Credentials = cc;
}
return areaService;
}
}
}
Jerarquía de herencia
System.Object
System.ComponentModel.MarshalByValueComponent
System.Web.Services.WebService
Microsoft.SharePoint.Portal.AreaService
Seguridad de subprocesos
Todos los miembros estáticos públicos (compartidos en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancia sean seguros para los subprocesos.
Vea también
Referencia
AreaService (Miembros)
Microsoft.SharePoint.Portal (Espacio de nombres)