You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve Getting Started Guide by removing inconsistencies in service names (dotnet#9659)
* Update how-to-host-and-run-a-basic-wcf-service.md
- Fixed formatting of Important section.
- Fixed inconsistency with different baseAddress in csharp and vb example (also aligned to what is used in other steps)
- Updated instruction how to verify that your service is running.
* Update how-to-host-and-run-a-basic-wcf-service.md
- Incorporate instructions how to disable Start WCF Service Host when debugging to avoid conflicts.
**Step 3** – Creates a <xref:System.ServiceModel.Description.ServiceEndpoint> instance. A service endpoint is composed of an address, a binding, and a service contract. The <xref:System.ServiceModel.Description.ServiceEndpoint> constructor therefore takes the service contract interface type, a binding, and an address. The service contract is `ICalculator`, which you defined and implement in the service type. The binding used in this sample is <xref:System.ServiceModel.WSHttpBinding> which is a built-in binding that is used for connecting to endpoints that conform to the WS-* specifications. For more information about WCF bindings, see [WCF Bindings Overview](bindings-overview.md). The address is appended to the base address to identify the endpoint. The address specified in this code is "CalculatorService" so the fully qualified address for the endpoint is `"http://localhost:8000/GettingStarted/CalculatorService"`.
140
140
141
-
> [!IMPORTANT]
142
-
> Adding a service endpoint is optional when using .NET Framework 4 or later. In these versions, if no endpoints are added in code or configuration, WCF adds one default endpoint for each combination of base address and contract implemented by the service. For more information about default endpoints see [Specifying an Endpoint Address](specifying-an-endpoint-address.md). For more information about default endpoints, bindings, and behaviors, see [Simplified Configuration](simplified-configuration.md) and [Simplified Configuration for WCF Services](./samples/simplified-configuration-for-wcf-services.md).
141
+
> [!IMPORTANT]
142
+
> Adding a service endpoint is optional when using .NET Framework 4 or later. In these versions, if no endpoints are added in code or configuration, WCF adds one default endpoint for each combination of base address and contract implemented by the service. For more information about default endpoints see [Specifying an Endpoint Address](specifying-an-endpoint-address.md). For more information about default endpoints, bindings, and behaviors, see [Simplified Configuration](simplified-configuration.md) and [Simplified Configuration for WCF Services](./samples/simplified-configuration-for-wcf-services.md).
143
143
144
144
**Step 4** – Enable metadata exchange. Clients will use metadata exchange to generate proxies that will be used to call the service operations. To enable metadata exchange create a <xref:System.ServiceModel.Description.ServiceMetadataBehavior> instance, set it’s <xref:System.ServiceModel.Description.ServiceMetadataBehavior.HttpGetEnabled%2A> property to `true`, and add the behavior to the <xref:System.ServiceModel.Description.ServiceDescription.Behaviors%2A> collection of the <xref:System.ServiceModel.ServiceHost> instance.
145
145
146
146
**Step 5** – Open the <xref:System.ServiceModel.ServiceHost> to listen for incoming messages. Notice the code waits for the user to hit enter. If you do not do this, the app will close immediately and the service will shut down.Also notice a try/catch block used. After the <xref:System.ServiceModel.ServiceHost> has been instantiated, all other code is placed in a try/catch block. For more information about safely catching exceptions thrown by <xref:System.ServiceModel.ServiceHost>, see [Use Close and Abort to release WCF client resources](samples/use-close-abort-release-wcf-client-resources.md)
147
147
148
148
> [!IMPORTANT]
149
-
> Edit App.config in GettingStartedLib to reflect the changes made in code:
150
-
> 1. Change line 14 to `<service name="GettingStartedLib.CalculatorService">`
151
-
> 2. Change line 17 to `<add baseAddress = "http://localhost:8000/GettingStarted/CalculatorService" />`
152
-
> 3. Change line 22 to `<endpoint address="" binding="wsHttpBinding" contract="GettingStartedLib.ICalculator">`
149
+
> When you add a WCF Service Library, Visual Studio can host it for you when you debug by starting a service host. To avoid conflicts you can disable this.
150
+
> 1. Open Project Properties for GettingStartedLib.
151
+
> 2. Go to **WCF Options** and uncheck **Start WCF Service Host when debugging**.
153
152
154
153
## Verify the service is working
155
154
156
155
1. Run the GettingStartedHost console application from inside Visual Studio.
157
156
158
157
The service must be run with administrator privileges. Because Visual Studio was opened with administrator privileges, GettingStartedHost is also run with administrator privileges. You can also open a new command prompt using **Run as administrator** and run service.exe within it.
159
158
160
-
2. Open a web browser and browse to the service's debug page at `http://localhost:8000/GettingStarted/CalculatorService`.
159
+
2. Open a web browser and browse to the service's debug page at `http://localhost:8000/GettingStarted/`. **Note! Ending slash is significant.**
161
160
162
161
## Example
163
162
@@ -243,7 +242,7 @@ namespace GettingStartedHost
243
242
staticvoidMain(string[] args)
244
243
{
245
244
// Step 1 of the address configuration procedure: Create a URI to serve as the base address.
0 commit comments