Skip to content

Commit 233f5e7

Browse files
committed
Edits
1 parent c57415c commit 233f5e7

File tree

1 file changed

+38
-28
lines changed

1 file changed

+38
-28
lines changed

docs/data-tools/walkthrough-creating-a-simple-wcf-service-in-windows-forms.md

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: ghogen
66
manager: mijacobs
77
ms.subservice: data-tools
88
ms.topic: how-to
9-
ms.date: 03/16/2025
9+
ms.date: 03/17/2025
1010
dev_langs:
1111
- VB
1212
- CSharp
@@ -30,33 +30,35 @@ This walkthrough demonstrates how to create a Windows Communication Foundation (
3030

3131
[Visual Studio](https://visualstudio.microsoft.com/downloads/?cid=learn-onpage-download-cta) with the **Windows Communication Foundation** component installed. To install it:
3232

33-
1. Open **Visual Studio Installer** or select **Tools** > **Get Tools and Features**.
34-
1. In the installer, choose **Modify** next to the version of Visual Studio you want to modify.
33+
1. Open **Visual Studio Installer** or select **Tools** > **Get Tools and Features** from the menu.
34+
1. In **Visual Studio Installer**, choose **Modify** next to the version of Visual Studio you want to modify.
3535
1. Select the **Individual components** tab, and then choose **Windows Communication Foundation** under **Development activities**.
3636
1. Select **Modify**.
3737

3838
For more information, see [Modify Visual Studio workloads, components, and language packs](../install/modify-visual-studio.md).
3939

40-
## Create a service
40+
## Create a WCF service
41+
42+
To create a WCF service in Visual Studio, follow these steps:
4143

4244
1. In Visual Studio, select **File** > **New** > **Project** from the menu.
4345

44-
1. On the **Create a new project** page, enter **wcf service library** in the search box. Select either the C# or Visual Basic template for **WCF Service Library**, and then select **Next**.
46+
2. On the **Create a new project** page, enter **wcf service library** in the search box. Select either the C# or Visual Basic template for **WCF Service Library**, and then select **Next**.
4547

46-
:::image type="content" alt-text="Screen shot that shows how to create a WCF Service Library project in Visual Studio." source="../data-tools/media/vs-2022/create-new-wcf-service-library.png":::
48+
:::image type="content" alt-text="Screenshot that shows how to create a WCF Service Library project in Visual Studio." source="../data-tools/media/vs-2022/create-new-wcf-service-library.png":::
4749

4850
> [!TIP]
4951
> If you don't see any templates, you might need to install the **Windows Communication Foundation** component of Visual Studio. For more information, see [Prerequisites](#prerequisites)
5052
51-
1. On the **Configure your new project** page, verify the settings, and then select **Create**.
53+
3. On the **Configure your new project** page, verify the settings, and then select **Create**.
5254

53-
This step creates a working WCF service that you can test and access. The following two steps demonstrate how to modify the default method to use a different data type. In a real application, you'd also add your own functions to the service.
55+
This step creates a working WCF service that you can test and access. The following steps demonstrate how to modify the default method to use a different data type. In a real application, you'd also add your own functions to the service.
5456

55-
1. In Solution Explorer, double-click **IService1.cs** or **IService1.vb** in your WCF service library project, depending on which type of project you created.
57+
4. In Solution Explorer, double-click **IService1.cs** or **IService1.vb** in your WCF service library project, depending on which type of project you created.
5658

57-
:::image type="content" alt-text="Screen shot that shows the IService1 file in Solution Explorer." source="../data-tools/media/wcf2.png":::
59+
:::image type="content" alt-text="Screenshot that shows the IService1 file in Solution Explorer." source="../data-tools/media/wcf2.png":::
5860

59-
1. Find the following line:
61+
5. Find the following line:
6062

6163
### [C#](#tab/csharp)
6264

@@ -68,7 +70,7 @@ For more information, see [Modify Visual Studio workloads, components, and langu
6870

6971
---
7072

71-
1. Change the type for the `value` parameter to string, as follows:
73+
6. Change the type for the `value` parameter to string, as follows:
7274

7375
### [C#](#tab/csharp)
7476

@@ -78,15 +80,15 @@ For more information, see [Modify Visual Studio workloads, components, and langu
7880

7981
:::code language="vb" source="../snippets/visualbasic/VS_Snippets_VBCSharp/wcfwalkthrough/vb/iservice1.vb" id="Snippet1":::
8082

81-
---
83+
In this code example, note the `OperationContract` attribute. This attribute is required for any method exposed by the service.
8284

83-
In the previous code example, note the `OperationContract` attribute. This attribute is required for any method exposed by the service.
85+
---
8486

85-
1. In Solution Explorer, double-click **Service1.vb** or **Service1.cs**.
87+
7. In Solution Explorer, double-click **Service1.cs** or **Service1.vb**.
8688

87-
:::image type="content" alt-text="Screen shot that shows the Service1 file in Solution Explorer." source="../data-tools/media/wcf3.png":::
89+
:::image type="content" alt-text="Screenshot that shows the Service1 file in Solution Explorer." source="../data-tools/media/wcf3.png":::
8890

89-
1. In the editor, find the following line:
91+
8. In the editor, find the following line:
9092

9193
### [C#](#tab/csharp)
9294

@@ -98,7 +100,7 @@ For more information, see [Modify Visual Studio workloads, components, and langu
98100

99101
---
100102

101-
1. Change the type for the `value` parameter to string, as follows:
103+
9. Change the type for the `value` parameter to string, as follows:
102104

103105
### [C#](#tab/csharp)
104106

@@ -110,34 +112,40 @@ For more information, see [Modify Visual Studio workloads, components, and langu
110112

111113
---
112114

113-
## Test the service
115+
## Test the WCF service
116+
117+
To test the WCF service you created, follow these steps:
114118

115119
1. Press **F5** to run the service.
116120

117121
The **WCF Test Client** form appears and loads the service.
118122

119-
1. In the **WCF Test Client** form, under **IService1**, double-click the **GetData()** method.
123+
1. Under **IService1**, double-click the **GetData()** method.
120124

121-
The **GetData** tab appears.
125+
The **GetData** tab appears in the **WCF Test Client** form.
122126

123127
:::image type="content" alt-text="Screenshot that shows the GetData method in the WCF Test Client form." source="../data-tools/media/wcf4.png":::
124128

125-
1. In the **Request** box, select the **Value** field and enter **Hello**.
129+
1. In the **Request** box of the **GetData** tab, select the **Value** field and enter **Hello**.
126130

127131
:::image type="content" alt-text="Screenshot that shows the Value field in the GetData tab." source="../data-tools/media/wcf5.png":::
128132

129133
1. Select the **Invoke** button. If a **Security Warning** dialog box appears, select **OK**.
130134

131135
The result displays in the **Response** box.
132136

133-
:::image type="content" alt-text="Screenshot that shows the result displayed in the Response box." source="../data-tools/media/wcf6.png":::
137+
:::image type="content" alt-text="Screenshot that shows the result displayed in the Response box in the GetData tab." source="../data-tools/media/wcf6.png":::
134138

135139
1. On the **File** menu, select **Exit** to close the test form.
136140

137-
## Access the Service
141+
## Access the WCF service
142+
143+
Now that you created and tested the WCF service, you can reference it from a project and use it to build a client application.
138144

139145
### Reference the WCF service
140146

147+
To reference the WCF service from a project, follow these steps:
148+
141149
1. Select **File** > **Add** > **New Project**.
142150

143151
1. In the **Add a New Project** window, choose either a C# or Visual Basic **Windows Forms App (.NET Framework)** project. Select **Next**, and then **Create** to create the project.
@@ -156,15 +164,17 @@ For more information, see [Modify Visual Studio workloads, components, and langu
156164

157165
### Build a client application
158166

159-
1. In Solution Explorer, depending on which type of project you created, double-click **Form1.cs**, or **Form1.vb**, in the Windows Forms app to open the Windows Forms Designer.
167+
1. In Solution Explorer, depending on which type of project you created, double-click **Form1.cs**, or **Form1.vb**, in the Windows Forms app.
168+
169+
The form opens in Windows Forms Designer.
160170

161171
1. Open the **Toolbox** by selecting **View** > **Toolbox** from the menu, or press **Ctrl**+**Alt**+**X** on the keyboard.
162172

163173
1. From the **Toolbox**, drag a **TextBox** control, a **Label** control, and a **Button** control onto the form.
164174

165-
:::image type="content" alt-text="Screenshot that shows how to add controls to the form." source="../data-tools/media/vs-2022/windows-communication-foundation-client-app.png" lightbox="../data-tools/media/vs-2022/windows-communication-foundation-client-app.png":::
175+
:::image type="content" alt-text="Screenshot that shows how to add controls to the client application form." source="../data-tools/media/vs-2022/windows-communication-foundation-client-app.png" lightbox="../data-tools/media/vs-2022/windows-communication-foundation-client-app.png":::
166176

167-
1. Double-click the **Button**, and add the following code in the `Click` event handler:
177+
1. Double-click the **Button** control, and add the following code in the `Click` event handler:
168178

169179
### [C#](#tab/csharp)
170180

@@ -180,7 +190,7 @@ For more information, see [Modify Visual Studio workloads, components, and langu
180190

181191
1. Press **F5** to run the project. Enter some text and select the button. The label displays **You entered:** followed by the text that you entered.
182192

183-
:::image type="content" alt-text="Screenshot that shows the result displayed in the running form." source="../data-tools/media/vs-2022/windows-forms-app.png":::
193+
:::image type="content" alt-text="Screenshot that shows the result displayed in the running client application form." source="../data-tools/media/vs-2022/windows-forms-app.png":::
184194

185195
## Related content
186196

0 commit comments

Comments
 (0)