共用方式為


SPWebService class

代表包含一或多個 Web 應用程式的 Web 服務。此 Web 服務可讓網頁瀏覽器存取 SharePoint 網站中的內容。

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
        Microsoft.SharePoint.Administration.SPService
          Microsoft.SharePoint.Administration.SPWebService

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
<GuidAttribute("45AD2BF2-4E3E-46A1-B477-126944C0ACEF")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPWebService _
    Inherits SPService _
    Implements IBackupRestoreConfiguration, IBackupRestore
'用途
Dim instance As SPWebService
[GuidAttribute("45AD2BF2-4E3E-46A1-B477-126944C0ACEF")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPWebService : SPService, 
    IBackupRestoreConfiguration, IBackupRestore

備註

SPWebService類別是主要SPWebApplication物件的容器。使用SPWebApplication類別之WebService屬性可傳回父項的 Web 應用程式的 Web 服務。若要傳回之目前的 Web 服務的參照,您可以使用SPWebService.ContentService。

若要傳回安裝在伺服器陣列中的 Web 服務的集合,請使用SPWebServiceCollection建構函式。

一般而言,您可以從ContentService屬性取得SPWebService物件。您也可以使用索引器,若要從集合中傳回單一的 Web 服務。例如,如果集合都會被指派至變數 myWebServices,使用myWebServices[index]以 C# 或 Visual Basic 中的myWebServices(index)index所在的名稱或 GUID 的識別 Web 服務。

Examples

下列範例會逐一查看所有的伺服器陣列中的 Web 服務,並變更的最大網站計數和每個 Web 應用程式所使用的所有內容資料庫的警告網站計數。

Dim webServices As New SPWebServiceCollection(SPFarm.Local)
Dim webService As SPWebService

For Each webService In  webServices
    Dim webApp As SPWebApplication

    For Each webApp In  webService.WebApplications

        If Not webApp.IsAdministrationWebApplication Then

            Dim contentDatabases As SPContentDatabaseCollection = webApp.ContentDatabases
            Dim database As SPContentDatabase

            For Each database In  contentDatabases
                database.WarningSiteCount = 4900
                database.MaximumSiteCount = 5000

                database.Update()
            Next database
        End If
    Next webApp
Next webService
SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);

foreach (SPWebService webService in webServices)
{

    foreach (SPWebApplication webApp in webService.WebApplications)
    {

        if (!webApp.IsAdministrationWebApplication)
        {
            SPContentDatabaseCollection contentDatabases = webApp.ContentDatabases;

            foreach (SPContentDatabase database in contentDatabases)
            {
                database.WarningSiteCount = 4900;
                database.MaximumSiteCount = 5000;

                database.Update();
            }
        }
    }
}

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

請參閱

參照

SPWebService members

Microsoft.SharePoint.Administration namespace