次の方法で共有


AreaService クラス (Microsoft.SharePoint.Portal)

現在は使用されていません。リモート クライアントに対してエリア インターフェイスを提供します。

名前空間: Microsoft.SharePoint.Portal
アセンブリ: Microsoft.SharePoint.Portal (microsoft.sharepoint.portal.dll 内)

構文

'宣言
<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
'使用
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

備考

Area Serviceは、Windows Server 2003 を実行する任意の Web サーバーで使用できます。AreaWebService プロキシを作成するには、以下の手順に従います。

  1. Visual Studio 2005 で、新しい WebService プロジェクトの参照フォルダを右クリックします。

  2. [URL] ボックスに、サーバーの URL (通常は https://server) に続けて「/_vti_bin/AreaService.asmx」(Web サービスを示すファイルのパス) と入力します。

  3. [移動] をクリックします。

  4. Visual Studio 2005 が Web サービスを検出したら、[Web 参照名] ボックスに「AreaWebService」と入力します。

次のコード例は、Area Service Web サービスの使用法を示しています。

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;
        }
   }
}

継承階層

System.Object
   System.ComponentModel.MarshalByValueComponent
     System.Web.Services.WebService
      Microsoft.SharePoint.Portal.AreaService

スレッドの安全性

この型のパブリックで静的な (Visual Basic では Shared) すべてのメンバは、スレッド セーフです。インスタンス メンバは、スレッド セーフであるとは保証されません。

関連項目

参照

AreaService メンバ
Microsoft.SharePoint.Portal 名前空間