組態編輯器工具 (SvcConfigEditor.exe)Configuration Editor Tool (SvcConfigEditor.exe)

Windows Communication Foundation (WCF) 服務組態編輯器 (SvcConfigEditor.exe) 可讓系統管理員和開發人員使用圖形化使用者介面建立並修改 WCF 服務的組態設定。The Windows Communication Foundation (WCF) Service Configuration Editor (SvcConfigEditor.exe) allows administrators and developers to create and modify configuration settings for WCF services using a graphical user interface. 有了這項工具,您可以管理 WCF 繫結、行為、服務及診斷的設定,而不用直接編輯 XML 組態檔。With this tool, you can manage settings for WCF bindings, behaviors, services, and diagnostics without having to directly edit XML configuration files.

服務組態編輯器位於 C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin 資料夾。Service Configuration Editor can be found in the C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin folder.

WCF 組態編輯器The WCF Configuration Editor

服務組態編輯器所提供的精靈會指引您完成設定 WCF 服務或用戶端的所有步驟。Service Configuration Editor comes with a wizard that guides you through all the steps in configuring a WCF service or client. 強烈建議您使用精靈,而不直接使用編輯器。You are strongly advised to use the wizard instead of the editor directly.

如果您已經擁有一些符合標準 System.Configuration 結構描述的組態檔,就可以透過使用者介面來管理繫結、行為、服務和診斷的特定設定。If you already have some configuration files that comply with the standard System.Configuration schema, you can manage specific settings for bindings, behavior, services, and diagnostics with the user interface. 服務組態編輯器可讓您管理現有 WCF 組態檔和可執行檔、COM+ 服務,以及 Web 託管服務的設定。The Service Configuration Editor enables you to manage the settings for existing WCF configuration files as well as executable files, COM+ services, and Web-hosted services. 使用服務組態編輯器開啟 Web 託管服務時,服務本身的組態和繼承自高層節點的組態區段都會顯示。When opening a Web-hosted service with Service Configuration Editor, both the service’s own configuration and inherited configurations sections of upper level nodes are shown.

因為 WCF 組態設定位於組態檔的 <system.serviceModel> 區段中,所以編輯器只會在這個項目的內容進行作業,不會存取同一個檔案中的其他項目。Because WCF configuration settings are located in the <system.serviceModel> section of the configuration file, the editor operates exclusively on the content of this element and does not access other elements in the same file. 您可以直接巡覽至現有的組態檔,或是選取包含服務、虛擬目錄或 COM+ 服務的組件。You can navigate to existing configuration files directly or you can select an assembly that contains a service, virtual directory, or COM+ service. 編輯器會載入特定服務的組態檔,並允許使用者加入新項目,或編輯以巢狀方式置於組態檔 <system.serviceModel> 區段中的現有項目。The editor loads the configuration file for that particular service and allows the user to either add new elements or edit existing elements nested in the <system.serviceModel> section of the configuration file.

編輯器支援 IntelliSense 並增強結構描述相容性。The editor supports IntelliSense and enforces schema compliance. 編輯器保證結果輸出符合組態檔的結構描述,且資料值有正確的語法,The resulting output is guaranteed to comply with the schema of the configuration file and to have syntactically correct data values. 但是不保證組態檔的語意為有效。However, the editor does not guarantee that the configuration file is semantically valid. 換句話說,編輯器不保證組態檔能夠與它所設定的服務搭配使用。In other words, the editor does not guarantee that the configuration file can work with the service it configures.

警告

一旦您修改了項目,編輯器便無法清除組態檔中的組態項目。The editor cannot purge a configuration element from the configuration file once you have modified the element. 例如,如果您使用編輯器將端點名稱設定非空白字串並加以儲存,則組態檔會有以下內容,如下列範例所示。For example, if you use the editor to set the endpoint name to a non-empty string and save it, the configuration file has the following content, as shown in the following example.

<endpoint binding="basicHttpBinding" name="somename" />

如果您嘗試將名稱設為空白字串並儲存檔案藉以移除名稱,則組態檔仍會包含 name 屬性,如下列範例所示。If you attempt to remove the name by setting it to an empty string and save the file, the configuration file still contains the name attribute, as shown in the following example.

<endpoint binding="basicHttpBinding" name="" />

若要清除該屬性,您必須使用其他文字編輯器手動編輯該項目。To purge the attribute, you must manually edit the element using another text editor.

當您使用 issueToken 端點行為的 clientCredential 項目時,應特別小心此問題。You should be especially careful with this issue when you use the issueToken element of the clientCredential Endpoint behavior. 具體來說,其 address 子項目的 localIssuer 屬性不能是空白字串。Specifically, the address attribute of its localIssuer sub-element must not be an empty string. 如果您已使用組態編輯器修改過 address 屬性,且要將該屬性完全移除,則應使用組態編輯器以外的工具來移除。If you have modified the address attribute using the Configuration Editor and want to remove it completely, you should do so using a tool other than the Editor. 否則,屬性會包含空白字串,而且您的應用程式會擲回例外狀況。Otherwise, the attribute contains an empty string and your application throws an exception.

使用組態編輯器Using the Configuration Editor

服務組態編輯器位於下列 Windows SDK 安裝位置:The Service Configuration Editor can be found at the following Windows SDK installation location:

C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SvcConfigEditor.exeC:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SvcConfigEditor.exe

啟動 [服務設定編輯器] 之後,您可以使用 [檔案] /[開啟] 功能表來流覽您要管理的服務或元件。After you launch the Service Configuration Editor, you can use the File/Open menu to browse for the service or assembly you want to manage. 您可以直接開啟組態檔,瀏覽 WCF/COM+ 服務,並開啟 Web 託管服務的組態檔。You can open configuration files directly, browse for WCF /COM+ services, and open configuration files for Web-hosted services.

服務組態編輯器的使用者介面共分為下列幾個區域:The Service Configuration Editor's user interface is divided into the following areas:

  • 樹狀檢閱窗格,在左側以樹狀顯示組態項目。Tree View Pane, which displays configuration elements in a tree structure on the left. 您可以用滑鼠右鍵按一下樹狀目錄中的節點來執行作業。You can perform operations in the tree by right-clicking the nodes.

  • 工作窗格,可在視窗左下角顯示目前項目的一般工作。Task Pane, which displays common tasks for current elements on the lower-left of the window

  • 詳細資料窗格,可在右側顯示 [樹狀檢視] 中所選取組態節點的詳細設定。Detail Pane, which displays detailed settings of the configuration node selected in the Tree View on the right.

開啟組態檔Opening a Configuration File

  1. 使用 [命令] 視窗流覽至您的 WCF 安裝位置,然後輸入 SvcConfigEditor.exe,以啟動 [服務設定編輯器]。Start Service Configuration Editor by using a command window to navigate to your WCF installation location, and then type SvcConfigEditor.exe.

  2. 從 [檔案] 功能表中,選取 [開啟],然後按一下您要管理的檔案類型。From the File menu, select Open and click the type of file you want to manage.

  3. 在 [開啟] 對話方塊中,流覽至您想要管理的特定檔案,然後按兩下該檔案。In the Open dialog box, navigate to the specific file you want to manage and double-click it.

檢視器會自動遵循組態合併路徑並建立合併組態的檢視。The viewer automatically follows the configuration merge path and creates a view of the merged configuration. 例如,非託管服務的實際設定是 Machine.config 和 app.config 的組合。任何變更都會套用至 Svcconfigeditor.exe 中的使用中檔案。For example, the actual configuration of a non-hosted service is a combination of Machine.config and App.config. Any changes are applied to the active file in the SvcConfigEditor. 如果您想要編輯組態合併路徑中的特定檔案,應該直接開啟它。If you want to edit a specific file in the configuration merge path, you should open it directly.

注意

組態編輯器會在目前已開啟的組態檔已在編輯器之外修改時,重新載入該組態檔。Configuration Editor reloads the currently opened configuration file when the latter has been modified outside the Editor. 發生這種情況時,所有未永久儲存在編輯器內的變更都會遺失。When this happens, all the changes that are not durably saved inside the Editor are lost. 如果持續發生重新載入,最有可能的原因是有服務不斷的存取組態檔,例如在背景中執行的防毒軟體。If reloading happens consistently, the most likely cause is a service that constantly accesses the configuration file, for example, an antivirus software running in the background. 若要解決這個問題,請確定該檔案開啟時,組態編輯器是唯一能夠存取該檔案的處理序。To resolve this, ensure that Configuration Editor is the only process that can access the file when it is opened.

服務Services

[服務] 節點會顯示目前已在設定檔中指派的所有服務。The Services node displays all of the services currently assigned in the configuration file. 樹狀目錄中的每個子節點會對應至設定檔中 < services > 元素的子項目。Each sub-node in the tree corresponds to a sub-element of the <services> element in the configuration file.

當您按一下 [服務] 節點時,您可以在 [詳細資料窗格] 的 [服務摘要] 頁面上,查看或執行工作。When you click the Services node, you can view or perform tasks on the service Summary Page in the Detail Pane.

建立新的服務組態Creating a new Service Configuration

您可以透過下列方式建立新的服務組態:You can create a new service configuration in the following ways:

  • 使用 Wizard:按一下 [建立新服務] 連結。Using a Wizard: Click the link Create a New Service… 在 [工作窗格] 或 [摘要] 頁面上啟動精靈。on the Task Pane or Summary Page to launch the wizard. 您也可以在 檔案 功能表中執行此動作->加入新專案You can also do so in the File menu -> Add New Item.

  • 手動建立:您可以在 [服務] 節點上按一下滑鼠右鍵,然後選擇 [新增服務]。Create manually: You can right-click the Services node and choose New Service.

建立新的服務端點組態Creating a new Service Endpoint Configuration

您可以透過下列方式建立新的服務端點組態:You can create a new service endpoint configuration in the following ways:

  • 使用 Wizard 建立:按一下 [建立新的服務端點] 連結。Create using a Wizard: click the link Create a New Service Endpoint… 在 [工作窗格] 或 [摘要] 頁面上啟動精靈。on the Task Pane or Summary Page to launch the wizard. 您也可以在 檔案 功能表中執行此動作->加入新專案You can also do so in the File menu -> Add New Item.

  • 手動建立:建立服務之後,您可以用滑鼠右鍵按一下 [端點] 節點,然後選擇 [新增服務端點]。Create manually: Once you created a Service, you can right-click the Endpoints node and choose "New Service Endpoint".

編輯服務組態Editing a Service Configuration

  1. 按一下 [服務] 節點。Click a Service node.

  2. 編輯屬性方格中的設定。Edit the settings in the property grids.

編輯服務端點組態Editing a Service Endpoint Configuration

  1. 按一下 [服務端點] 節點。Click a Service Endpoint node.

  2. 編輯屬性方格中的設定。Edit the settings in the property grids.

加入基底位址Adding a Base Address

  1. 按一下 [主機] 節點。Click the Host node.

  2. 按一下 [新增 ... ]Click the New… [基底位址] 區段中的按鈕。button in the Base Addresses section.

  3. 在對話方塊中輸入基底位址 URI。Type in the base address URI in the dialog box.

  4. 按一下 [確定]。Click OK.

注意

您無法在此工具內編輯<baseAddressPrefixFilters >的值。You cannot edit the value of <baseAddressPrefixFilters> inside this tool. 若要新增或修改這個項目,您應使用文字編輯器或 Visual Studio。To add or modify this element, you should use a text editor or Visual Studio.

用戶端Client

[用戶端] 節點會顯示設定檔中的所有用戶端端點。The Client node displays all of the client endpoints in the configuration file. 樹狀目錄中的每個子節點會對應至設定檔中 < client > 元素的子項目。Every sub-node in the tree corresponds to a sub-element of the <client> element in the configuration file.

當您按一下 [用戶端] 節點時,您可以在 [詳細資料窗格] 的用戶端 [摘要] 頁面上,查看或執行工作。When you click the Client node, you can view or perform tasks on the client Summary Page in the Detail Pane.

建立新的用戶端端點組態Creating a new Client Endpoint Configuration

您可以透過下列方式來建立新的用戶端端點組態:You can create a new client endpoint configuration in the following ways:

  • 由 Wizard 建立:按一下 [建立新用戶端] 連結。Create by Wizard: Click the link Create a New Client… 在視窗左下角的 [工作窗格] 或 [摘要] 頁面上,啟動精靈。on the Task Pane on the lower-left of the window, or Summary Page to launch the wizard. 您也可以在 檔案 功能表中執行此動作->加入新專案You can also do so in the File menu -> Add New Item. 精靈會提示您指向服務組態的位置,從這裡產生用戶端組態。The wizard prompts you to point to the location of the service configuration, from which the client configuration is generated. 然後您可以選擇要連接的服務端點。You can then choose the service endpoint to connect to.

  • 手動建立:以滑鼠右鍵按一下 [用戶端] 底下的 [端點] 節點,然後選擇 [新增用戶端端點]。Create manually: Right-click the Endpoints node under Client, and choose New Client Endpoint.

編輯用戶端端點組態Editing a Client Endpoint Configuration

  1. 按一下 [用戶端端點] 節點。Click a Client Endpoint node.

  2. 編輯屬性方格中的設定。Edit the settings in the property grids.

標準端點Standard Endpoint

標準端點是專屬端點,可將位址、連絡人和繫結的一個或多個部分設為預設值。Standard endpoints are specialized endpoints that have one or more aspects of the address, contract and binding set to default values.

這類設定會儲存在 [標準端點] 節點中。Such configuration settings are stored in the Standard Endpoint node. [標準端點] 節點會顯示設定檔中的所有標準端點設定。The Standard Endpoint node displays all of the standard endpoint settings in the configuration file. 樹狀目錄中的每個子節點會對應至設定檔中 <standardEndpoints> 元素的子項目。Every sub-node in the tree corresponds to a sub-element in the <standardEndpoints> element in the configuration file.

當您按一下 [標準端點] 節點時,可以在 [詳細資料窗格] 的標準端點 [摘要] 頁面上,查看或執行工作。When you click the Standard Endpoint node, you can view or perform tasks on the standard endpoint Summary Page in the Detail Pane.

建立新的標準端點組態Creating a New Standard Endpoint Configuration

您可以透過下列方式建立新的標準端點組態:You can create a new standard endpoint configuration in the following ways:

  • 以滑鼠右鍵按一下 [標準端點] 節點,然後選取 [新增標準端點設定]。Right-click the Standard Endpoint node and select New Standard Endpoint Configuration… 在對話方塊中選取系結類型,然後按一下 [確定]Select the binding type in the dialog box and click OK.

  • 選取 [標準端點] 節點,然後按一下 [新增標準端點設定]。Select the Standard Endpoint node and click New Standard Endpoint Configuration… 在視窗左下角的 [工作窗格] 中。in the Task Pane on the lower-left of the window.

[建立新的標準端點] 對話方塊會顯示並列出所有已註冊的標準端點類型。The Creating a New Standard Endpoint dialog box displays and lists all registered standard endpoint types.

檢視及編輯標準端點組態Viewing and Editing a Standard Endpoint Configuration

您可以透過下列方式開啟標準端點組態進行檢視和編輯:You can open a standard endpoint configuration for viewing and editing in the following ways:

  • 按一下以展開 [標準端點] 節點,然後按一下個別的 [端點] 子節點。Click to expand the Standard Endpoint node and click the respective endpoint sub-node.

  • 按一下 [標準端點] 節點,然後按一下 [詳細資料] 窗格上的個別端點。Click the Standard Endpoint node and click the respective endpoint on the Detail pane.

端點的屬性會在右窗格中顯示供您編輯。Attributes for the endpoint are shown in the right pane for editing.

刪除標準端點組態Deleting a Standard Endpoint Configuration

您可以透過下列方式刪除標準端點組態:You can delete a standard endpoint configuration in the following ways:

  • 按一下以展開 [標準端點] 節點,然後以滑鼠右鍵按一下個別的 [端點] 子節點。Click to expand the Standard Endpoint node and right-click the respective endpoint sub-node. 使用內容命令 [刪除標準端點設定] 來刪除端點。Use the context command Delete Standard Endpoint Configuration to delete the endpoint.

  • 按一下 [標準端點] 節點。Click the Standard Endpoint node. 在工作窗格中,按一下 [刪除標準端點設定]。In the Task pane, click Delete Standard Endpoint Configuration.

如果標準端點正在使用中,當您嘗試刪除它時,就會顯示警告訊息:標準端點正在使用中。如果您現在刪除它,請務必在設定的其他部分(例如,在服務端點或用戶端端點)中刪除其所有參考。否則,設定將會無效,且下次無法開啟。您確定要刪除標準端點嗎?If the standard endpoint is in used, a warning message is displayed when you attempt to delete it: The standard endpoint is in use. If you delete it now, please be sure to delete all of its references in other parts of the configuration (for example, in the service endpoint or client endpoint). Otherwise, the configuration will be invalid and cannot be opened next time. Are you sure you want to delete the standard endpoint?"

繫結Binding

繫結組態是用來設定端點上的繫結。Binding configurations are used to configure bindings on endpoints. 這類設定會儲存在 [系結] 節點中。Such configuration settings are stored in the Binding node. 端點會依據名稱參考繫結組態,而多個端點可參考單一繫結組態。Endpoints reference binding configurations by name and multiple endpoints can reference a single binding configuration.

[系結 ] 節點會顯示設定檔中的所有系結設定。The Bindings node displays all of the binding settings in the configuration file. 樹狀目錄中的每個子節點會對應至設定檔中 < bindings > 元素的子項目。Every sub-node in the tree corresponds to a sub-element in the <bindings> element in the configuration file.

當您按一下 [系結]節點時,可以在 [詳細資料窗格] 的 [系結摘要] 頁面上,查看或執行工作。When you click the Bindings node, you can view or perform tasks on the binding Summary Page in the Detail Pane.

建立新的繫結組態Creating a New Binding Configuration

您可以透過下列方式建立新的繫結組態。You can create a new binding configuration in the following ways.

  • 以滑鼠右鍵按一下 [系結] 節點,然後選取 [新增系結設定]。Right-click the Bindings node and select New Binding Configuration 在對話方塊中選取系結類型,然後按一下 [確定]Select the binding type in the dialog box and click OK.

  • 選取 [系結]節點,然後按一下 [新增系結設定]。Select the Bindings node and click New Binding Configuration 在視窗左下角的 [工作窗格] 中。in the Task Pane on the lower-left of the window.

  • 在服務或用戶端摘要頁面中,按一下 [系結設定 ] 欄位中的 [ 按一下以建立],為對應的端點建立系結設定。In the service or client summary page, click Click to Create in the Binding Configuration field to create a binding configuration for the corresponding endpoint.

將繫結項目擴充功能加入至自訂繫結中Adding Binding Element Extensions to a Custom Binding

  1. 選取您要在其中新增擴充功能項目的繫結。Select the binding you want to add an extension element to.

  2. 按一下 [加入]。Click Add.

  3. 從可用延伸清單中,選取您要加入的繫結項目延伸。From the list of available extensions, select the binding element extension you want to add. 若要選取多個項目,請同時按下 CTRL 鍵。To select multiple items, press the CTRL key simultaneously.

  4. 按一下 [加入]。Click Add.

調整自訂繫結中的擴充功能位置Adjusting the Extension Position in a Custom Binding

自訂繫結是一種會形成堆疊的繫結項目集合。A custom binding is a collection of binding elements that form a stack. 堆疊上的每個繫結項目都有專屬的組態設定。Each binding element on the stack has its own configuration settings. 自訂繫結中的繫結項目擴充功能順序代表每個擴充功能在堆疊中的位置。The order of the binding element extensions in a custom binding indicates their positions in the stack. 在堆疊頂端的項目會優先套用。Elements at the top of the stack are applied first. 若要變更順序:To change the ordering:

  1. 選取自訂繫結節點。Select the custom binding node.

  2. 在 [繫結項目延伸位置] 區段中選取一個系結延伸模組元素。Select one binding extension element in the Binding Element Extension Position section.

  3. 使用清單左側的 [向上] 或 [向下] 按鈕,變更選取專案的位置。Use the Up or Down button on the left side of the list to change the position of the selected element.

編輯自訂繫結中繫結項目擴充功能的組態Editing the Configuration of Binding Element Extensions in a Custom Binding

  1. 選取樹狀目錄中的繫結程序節點。Select the binding node in the tree.

  2. 選取包含您要編輯之項目的自訂繫結。Select the custom binding that contains the element you want to edit.

  3. 選取您要編輯的繫結項目延伸。Select the binding element extension you want to edit. 項目設定會出現在右窗格中供您進行編輯。The settings of the element appear in the right pane, where they can be edited.

診斷Diagnostics

[診斷] 節點會顯示設定檔中的所有診斷設定。The Diagnostics node displays all of the diagnostic settings in the configuration file. 它可讓您開啟或關閉效能計數器、啟用或停用 Windows Management Instrumentation (WMI)、設定 WCF 追蹤,以及設定 WCF 訊息記錄。It enables you to turn performance counters on or off, enable or disable Windows Management Instrumentation (WMI), configure WCF tracing, and configure WCF message logging. [診斷] 節點中的設定會對應至設定檔中 <system.serviceModel> 的 [< system.diagnostics >] 區段和 [<diagnostics>] 區段。The settings in the Diagnostics node correspond to the <system.diagnostics> section, and <diagnostics> section in <system.serviceModel> in the configuration file.

當您按一下 [診斷] 節點時,可以在 [詳細資料窗格] 的診斷 [摘要] 頁面上,查看或執行工作。When you click the Diagnostics node, you can view or perform tasks on the diagnostics Summary Page in the Detail Pane.

設定效能計數器與 WMIConfiguring performance counters and WMI

  1. 按一下 [診斷] 節點。Click the Diagnostics node.

  2. 按一下 [切換效能計數器]。Click Toggle Performance Counters. 效能計數器具有三種狀態:Off (default)、ServiceOnly 和 All。The performance counter has three states: Off (default), ServiceOnly, and All. 按一下連結,即可切換設定這三種狀態。Clicking the link toggles the setting among these three states.

設定 WMI 提供者Configuring WMI Provider

  1. 按一下 [診斷] 節點。Click the Diagnostics node.

  2. 若要啟用 WMI 提供者,請按一下 [啟用 Wmi 提供者] 連結。To enable WMI provider, click the Enable WMI Provider link.

啟用 WCF 追蹤Enabling WCF Tracing

您可以使用標準屬性來建立 WCF 追蹤檔,或是設定自訂追蹤檔。You can create a WCF trace file with standard properties or set up a custom trace file.

  1. 按一下 [診斷] 節點。Click the Diagnostics node.

  2. 按一下 [啟用追蹤]。Click Enable Tracing.

  3. 按一下 [追蹤層級] 連結,以調整追蹤層級。Click the Trace Level link to adjust the trace level. 追蹤層級共有六個:關閉、關鍵、錯誤、警告、資訊與詳細資訊。There are six trace levels: Off, Critical, Error, Warning, Information, and Verbose. [活動追蹤] 與 [傳播活動] 選項可讓您使用 WCF 活動追蹤功能。The Activity Tracing and Propagate Activity option enable you to use the WCF activity tracing feature.

  4. 您可以按一下追蹤接聽項名稱,指定追蹤檔案與選項。Click the trace listener name to specify the trace file and options.

啟用 WCF 記錄Enabling WCF Logging

您可以使用標準屬性來建立 WCF 追蹤檔,或是設定自訂追蹤檔。You can create a WCF trace file with standard properties or set up a custom trace file.

  1. 按一下 [診斷] 節點。Click the Diagnostics node.

  2. 按一下 [啟用訊息記錄]。Click Enable Message Logging.

  3. 按一下 [記錄層級] 連結,以調整記錄層級。Click the Log Level link to adjust the log level. 記錄層級共有三個:格式錯誤、服務和傳輸。There are three log levels: Malformed, Service, and Transport.

  4. 您可以按一下接聽項名稱,指定記錄檔案與選項。Click the listener name to specify the log file and options.

注意

如果您想要在關閉應用程式時自動清除追蹤和訊息記錄,請啟用 [自動清除] 選項。If you want the trace and message logs to be flushed automatically when your application is closed, enable the Auto Flush option.

[診斷 摘要] 頁面可讓您完成設定診斷作業的最常見工作。The Diagnostics Summary Page enables you to accomplish the most common tasks in configuring diagnostics. 不過,如果您想要手動編輯 [接聽程式] 和 [來源] 設定,必須展開 [診斷] 節點,然後編輯 [訊息記錄 ]、[ 接聽程式來源] 節點中的設定。However, if you want to manually edit the Listeners and Sources settings, you must expand the Diagnostics node and edit settings in Message Logging, Listeners and Sources node.

啟用 WCF 自訂追蹤或訊息記錄Enabling WCF Custom Tracing or Message Logging

  1. 按一下 [診斷] 節點,然後將它展開。Click the Diagnostics node, and expand it.

  2. 以滑鼠右鍵按一下 [接聽程式] 節點,然後選取 [新增接聽程式 ]Right-click the Listeners node and select New Listener.

  3. 在 [ InitData ] 欄位中輸入追蹤檔名稱。Type in the trace file name in the InitData field. 您可以按一下 [...]按鈕以流覽至路徑。You can click the "…" button to browse to a path.

  4. 按一下 [ TypeName ] 行就會顯示「...」button.Clicking the TypeName line displays a "…" button. 按一下此按鈕以開啟 [追蹤接聽程式類型瀏覽器] ,您可以用來尋找已經安裝的預先設定追蹤接聽項。Click this button to open the Trace Listener Type Browser, which you can use to find pre-configured trace listeners that are already installed.

  5. 請注意 [來源] 區段。Note the Source section. 按一下此區段中的 [新增] 以開啟含有下拉式功能表的對話方塊,其中會列出可用的追蹤來源。Click Add in this section to open a dialog box with a drop-down menu, which lists available tracing sources. 選取追蹤來源,然後按一下 [確定]Select a tracing source and click OK.

  6. 若要編輯訊息記錄設定,請按一下 [訊息記錄] 節點。To edit Message Logging settings, click the Message Logging node. 您可以編輯屬性方格中的設定。You can edit the settings in the property grid.

進階Advanced

「行為」Behaviors

[行為] 節點會顯示目前定義于設定檔中的行為。The Behaviors node displays the behaviors that are currently defined in the configuration file.

行為組態是用來設定端點與服務的行為。Behavior configurations are used to configure behaviors of endpoints and services. 這類設定會儲存在 [服務行為] 和 [端點行為] 底下的 [ Advanced ] 節點中。Such configuration settings are stored in the Advanced node under Service Behaviors and Endpoint Behaviors. 服務會使用服務行為,而端點則會使用端點行為。Service behaviors are used by services; whereas endpoint behaviors by endpoints.

行為是一種會形成堆疊之延伸項目的集合。Behaviors are a collection of extension elements that for a stack. 在堆疊頂端的項目會優先套用。The element at the top of the stack is applied first. 每個延伸項目可以擁有專屬的組態。Each extension element can have its own configuration.

建立新的行為組態Creating a new Behavior Configuration

您可以透過下列兩種方式建立新的行為組態。You can create a new behavior configuration in two ways.

  • 以滑鼠右鍵按一下其中一個行為節點,然後選取 [新增行為設定 ...]Right-click one of the behavior nodes and select "New Behavior Configuration…

  • 選取其中一個行為節點,然後按一下 [新增行為設定]。Select one of the behavior nodes and click the New Behavior Configuration 在視窗左下角的 [工作窗格] 中。in the Task Pane on the lower-left of the window.

將行為項目延伸加入至行為中Adding Behavior Element Extensions to a Behavior
  1. 選取其中一個行為節點。Select one of the behavior nodes.

  2. 選取您要編輯的行為。Select the behavior you want edit.

  3. 按一下 [加入]。Click Add.

  4. 從可用擴充功能清單中,選取您要新增的行為項目擴充功能。From the list of available extensions, select the behavior element extension you want to add.

  5. 按一下 [加入]。Click Add.

調整行為中的延伸位置Adjusting the Extension Position in a Behavior

行為是一種會形成堆疊之項目的集合。Behaviors are collections of elements that form a stack. 堆疊上的每個項目都有專屬的組態。Each element on the stack has its own configuration. 行為中的行為項目延伸順序代表每個延伸在堆疊中的位置。The order of the behavior element extensions in a behavior indicates their positions in the stack. 在堆疊頂端的項目會優先套用。Elements at the top of the stack are applied first. 若要變更順序:To change the ordering:

  1. 選取其中一個行為節點。Select one of the behavior nodes.

  2. 選取您要編輯的行為。Select the behavior you want edit.

  3. 在 [行為專案延伸位置] 區段中選取行為延伸模組元素。Select a behavior extension element in the Behavior Element Extension Position section.

  4. 使用清單左側的 [向上] 或 [向下] 按鈕,變更選取專案的位置。Use the Up or Down button on the left side of the list to change the position of the selected element.

編輯行為項目擴充功能的組態Editing the Configuration of Behavior Element Extensions
  1. 選取樹狀目錄的其中一個行為節點。Select one of the behavior nodes in the tree.

  2. 選取包含您要編輯之項目的行為。Select the behavior that contains the element you want to edit.

  3. 選取您要編輯的行為項目擴充功能。Select the behavior element extension you want to edit. 項目設定會出現在右窗格中供您進行編輯。The settings of the element appear in the right pane where they can be edited.

ProtocolMappingProtocolMapping

這個區段可讓您透過通訊協定位址配置與可能的繫結之間已定義的對應,針對不同的通訊協定設定預設的繫結型別,例如 http、tcp、MSMQ 或 net.pipe。This section allows you to set default binding types for different protocols such as http, tcp, MSMQ or net.pipe through defined mapping between protocol address schemes and the possible bindings. 您也可以加入其他通訊協定的新對應。You can also add new mappings to other protocols.

延伸模組Extensions

您可以註冊新的系結延伸、繫結項目延伸、標準端點延伸和行為延伸模組,以便在 WCF 設定中使用。New binding extensions, binding element extensions, standard endpoint extensions and behavior extensions can be registered for use in WCF configuration. 擴充功能是名稱/型別的配對。Extensions are name/type pairs. 名稱可定義組態中延伸的名稱,而型別則可實作延伸。The name defines the name of the extension in configuration, whereas the type implements the extension. 延伸有四種型別:There are four types of extensions:

  • 繫結延伸可定義整個繫結型別。Binding extensions define an entire binding type. 範例:basicHttpBindingExample: basicHttpBinding.

  • 繫結項目延伸可定義繫結項目。Binding element extensions define an element of a binding. 範例:textMessageEncodingExample: textMessageEncoding.

  • 標準端點延伸可定義整個標準端點。Standard endpoint extensions define an entire standard endpoint. 範例:discoveryEndpointExample: discoveryEndpoint.

  • 行為項目延伸可定義行為項目。Behavior element extensions define an element of a behavior. 範例:clientViaExample: clientVia.

已經於組態中註冊的擴充功能可比照同類型的任何其他 WCF 元件使用。Extensions that have been registered in configuration can be used like any other WCF component of the same type.

加入新的延伸Adding a new extension

在進階節點中選取其中一個延伸節點:Select one of the extension nodes in the advanced nodes:

  1. 按一下 [新增]。Click New.

  2. 輸入名稱和型別。Enter a name and type.

  3. 按一下 [確定]。Click OK.

  4. 擴充功能現在會出現在編輯器的適當位置中。The extension now appears in the appropriate place in the Editor. 例如,如果您新增行為項目延伸,則這個功能會出現在可用延伸清單中。For example, if you add a behavior element extension, it appears in the list of available extensions.

裝載環境Hosting Environment

這個區段可讓您定義服務裝載環境的執行個體化設定。This section allows you to define instantiation settings for the service hosting environment.

使用精靈來建立組態檔Creating a Configuration File Using the Wizard

建立新組態檔的一個方法是使用 [新增服務項目精靈]。One way to create a new configuration file is to use the New Service Element Wizard. 此嚮導會尋找與電腦上的 WCF 相容的已安裝服務類型和其他專案(包括 COM + 和 Web 裝載的虛擬目錄),並載入這些專案,讓建立設定更為簡化。The wizard finds the installed service types and other elements compatible with WCF on the computer, including COM+ and Web-hosted virtual directories, and loads them to make creating the configuration much more streamlined.

建立組態檔Creating a Configuration File

  1. 使用 [命令] 視窗流覽至您的 WCF 安裝位置,然後輸入 SvcConfigEditor.exe,以啟動 [服務設定編輯器]。Start Service Configuration Editor by using a command window to navigate to your WCF installation location, and then type SvcConfigEditor.exe.

  2. 從 [檔案] 功能表中,選取 [開啟],然後按一下 [可執行檔]、[ Com + 服務] 或 [ WebHosted 服務],視您要建立的配置檔案類型而定。From the File menu, select Open and click Executable, COM+ Service, or WebHosted Service, depending on the type of configuration file you want to create.

  3. 在 [開啟] 對話方塊中,流覽至您想要建立設定檔的特定檔案,然後按兩下該檔案。In the Open dialog box, navigate to the specific file you want to create a configuration file for and double-click it.

  4. 在 [檔案] 功能表中,指向 [加入新專案],然後按一下 [服務]。In the File menu, point to Add New Item and click Service. [新增服務項目精靈] 隨即開啟。The New Service Element Wizard opens.

  5. 依照精靈中的步驟執行,以建立新服務。Follow the steps in the wizard to create the new service.

注意

如果您要從精靈所產生的組態檔中使用 NetPeerTcpBinding,您必須手動新增繫結組態項目,並將其 mode 項目的 security 屬性修改為 [無]。If you want to use the NetPeerTcpBinding from the configuration file generated by the Wizard, you have to manually add a binding configuration element and modify the mode attribute of its security element to "None".

設定 COM+Configuring COM+

服務組態編輯器可讓您針對現有的 COM+ 應用程式建立新的組態檔,或是編輯現有的 COM+ 組態。The Service Configuration Editor enables you to create a new configuration file for an existing COM+ application, or edit an existing COM+ configuration. 只有當設定檔中存在 < comContract > 區段時,才會顯示 [ COM 合約] 節點。The COM Contract node is only visible when the <comContract> section exists in the configuration file.

建立新 COM+ 組態Creating a New COM+ Configuration

在建立新的 COM+ 組態之前,請先確定您的 COM+ 應用程式已安裝在 [元件服務] 中,並在 [全域組件快取] (GAC) 中註冊。Before creating a new COM+ configuration, make sure that your COM+ application is installed in Component Services, and registered in the Global Assembly Cache (GAC).

  1. 選取 [ 檔案] 功能表->整合 -> com + 應用程式。Select File menu -> Integrate -> COM+ Application. 這個作業會關閉目前開啟的檔案。This operation closes the current opened file. 如果目前檔案中包含未儲存的資料,就會出現 [儲存] 對話方塊。If there is unsaved data in the current file, a Save dialog appears. 接著會啟動Com + 整合嚮導The COM+ Integration Wizard is then launched.

  2. 從第一頁的樹狀目錄中選取 COM+ 應用程式。In the first page, select the COM+ application from the tree. 如果您在樹狀目錄中找不到您的 COM+ 應用程式,請確認該應用程式是否已經安裝在 [元件服務] 中,並且在 [全域組件快取] (GAC) 中註冊。If you cannot find your COM+ application in the tree, verify that it is installed in the Component Services and registered in the Global Assembly Cache (GAC).

  3. 在下一頁,選取您要公開為 WCF 服務的方法。In the next page, select which method(s) you want to expose as WCF services. 預設會顯示並選取 COM+ 應用程式支援的所有方法。All the supported methods in the COM+ application are displayed and selected by default.

  4. 選擇裝載的方法。Choose a hosting method.

  5. 依據精靈中的指示進行其他設定。Configure other settings according to the guides in the wizard.

  6. 服務組態編輯器會在背景中使用 ComSvcConfig.exe 來產生組態檔。Service Configuration Editor utilizes ComSvcConfig.exe in the background to generate configuration file. 完成後,您就可以檢視摘要並結束精靈。After this is completed, you can view a summary and exit the wizard. 產生的組態檔隨即開啟,方便您直接進行編輯。The generated configuration file is opened so that you can edit it directly.

編輯現有的 COM+ 組態Editing an Existing COM+ Configuration

  1. 選取 [ 檔案] 功能表->開啟 -> com + 服務Select File menu -> Open -> COM+ Service

  2. 從清單中選取您要編輯的 COM+ 服務。Select the COM+ Service you want to edit from the list.

  3. 編輯 [ COM 合約] 節點中的設定。Edit configuration settings in the COM Contracts node.

    注意

    您也可以直接開啟並編輯包含 COM 合約的組態檔。You can also directly open and edit a configuration file that contains COM contracts.

安全性Security

不保證組態編輯器產生的服務組態檔是安全的。A service configuration file generated by the Configuration Editor is not guaranteed to be secure. 請參閱安全性檔,以瞭解如何保護您的 WCF 服務。Please refer to the Security documentation to find out how to secure your WCF services.

此外,組態編輯器只能用於讀取和寫入有效的 WCF 組態項目。In addition, the Configuration Editor can only be used to read and write valid WCF configuration elements. 該工具會忽略符合結構描述、使用者定義的項目。The tool ignores schema-compliant, user-defined elements. 它也不會嘗試將這些項目從組態檔中移除,或判斷其對已知 WCF 項目的影響。It also does not attempt remove these elements from the configuration file or determine their effects on the known WCF elements. 使用者應負責判斷這些項目是否會對應用程式或系統造成威脅。It is the user’s responsibility to determine whether these elements pose a threat to the application or the system.