Skip to content

Commit 8cc2e9c

Browse files
v-thprav-thpra
authored andcommitted
Batch 33
1 parent 20e9ae3 commit 8cc2e9c

17 files changed

+54
-54
lines changed

docs/framework/wcf/samples/membership-and-role-provider.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ The Membership and Role Provider sample demonstrates how a service can use the A
174174

175175
The certificate is stored in My (Personal) store under the LocalMachine store location.
176176

177-
```
177+
```bat
178178
echo ************
179179
echo Server cert setup starting
180180
echo %SERVER_NAME%
@@ -188,6 +188,6 @@ The Membership and Role Provider sample demonstrates how a service can use the A
188188
189189
The following lines in the Setup.bat batch file copy the server certificate into the client trusted people store. This step is required because certificates generated by Makecert.exe are not implicitly trusted by the client system. If you already have a certificate that is rooted in a client trusted root certificate—for example, a Microsoft-issued certificate—this step of populating the client certificate store with the server certificate is not required.
190190
191-
```
191+
```bat
192192
certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople
193193
```

docs/framework/wcf/samples/message-inspectors.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This sample demonstrates how to implement and configure client and service messa
1313
## Message Inspector
1414
Client message inspectors implement the <xref:System.ServiceModel.Dispatcher.IClientMessageInspector> interface and service message inspectors implement the <xref:System.ServiceModel.Dispatcher.IDispatchMessageInspector> interface. The implementations can be combined into a single class to form a message inspector that works for both sides. This sample implements such a combined message inspector. The inspector is constructed passing in a set of schemas against which incoming and outgoing messages are validated and allows the developer to specify whether incoming or outgoing messages are validated and whether the inspector is in dispatch or client mode, which affects the error handling as discussed later in this topic.
1515

16-
```
16+
```csharp
1717
public class SchemaValidationMessageInspector : IClientMessageInspector, IDispatchMessageInspector
1818
{
1919
XmlSchemaSet schemaSet;
@@ -37,7 +37,7 @@ public class SchemaValidationMessageInspector : IClientMessageInspector, IDispat
3737

3838
<xref:System.ServiceModel.Dispatcher.IDispatchMessageInspector.AfterReceiveRequest%2A> is invoked by the dispatcher when a message has been received, processed by the channel stack and assigned to a service, but before it is deserialized and dispatched to an operation. If the incoming message was encrypted, the message is already decrypted when it reaches the message inspector. The method gets the `request` message passed as a reference parameter, which allows the message to be inspected, manipulated or replaced as required. The return value can be any object and is used as a correlation state object that is passed to <xref:System.ServiceModel.Dispatcher.IDispatchMessageInspector.BeforeSendReply%2A> when the service returns a reply to the current message. In this sample, <xref:System.ServiceModel.Dispatcher.IDispatchMessageInspector.AfterReceiveRequest%2A> delegates the inspection (validation) of the message to the private, local method `ValidateMessageBody` and returns no correlation state object. This method ensures that no invalid messages pass into the service.
3939

40-
```
40+
```csharp
4141
object IDispatchMessageInspector.AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
4242
{
4343
if (validateRequest)
@@ -54,7 +54,7 @@ object IDispatchMessageInspector.AfterReceiveRequest(ref System.ServiceModel.Cha
5454

5555
If a validation error occurs on the service, the `ValidateMessageBody` method throws <xref:System.ServiceModel.FaultException>-derived exceptions. In <xref:System.ServiceModel.Dispatcher.IDispatchMessageInspector.AfterReceiveRequest%2A>, these exceptions can be put into the service model infrastructure where they are automatically transformed into SOAP faults and relayed to the client. In <xref:System.ServiceModel.Dispatcher.IDispatchMessageInspector.BeforeSendReply%2A>, <xref:System.ServiceModel.FaultException> exceptions must not be put into the infrastructure, because the transformation of fault exceptions thrown by the service occurs before the message inspector is called. Therefore the following implementation catches the known `ReplyValidationFault` exception and replaces the reply message with an explicit fault message. This method ensures that no invalid messages are returned by the service implementation.
5656

57-
```
57+
```csharp
5858
void IDispatchMessageInspector.BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
5959
{
6060
if (validateReply)
@@ -82,7 +82,7 @@ void IDispatchMessageInspector.BeforeSendReply(ref System.ServiceModel.Channels.
8282

8383
This <xref:System.ServiceModel.Dispatcher.IClientMessageInspector.BeforeSendRequest%2A> implementation ensures that no invalid messages are sent to the service.
8484

85-
```
85+
```csharp
8686
object IClientMessageInspector.BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel)
8787
{
8888
if (validateRequest)
@@ -95,7 +95,7 @@ object IClientMessageInspector.BeforeSendRequest(ref System.ServiceModel.Channel
9595

9696
The `AfterReceiveReply` implementation ensures that no invalid messages received from the service are relayed to the client user code.
9797

98-
```
98+
```csharp
9999
void IClientMessageInspector.AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
100100
{
101101
if (validateReply)
@@ -109,7 +109,7 @@ void IClientMessageInspector.AfterReceiveReply(ref System.ServiceModel.Channels.
109109

110110
If no error occurs, a new message is constructed that copies the properties and headers from the original message and uses the now-validated infoset in the memory stream, which is wrapped by an <xref:System.Xml.XmlDictionaryReader> and added to the replacement message.
111111

112-
```
112+
```csharp
113113
void ValidateMessageBody(ref System.ServiceModel.Channels.Message message, bool isRequest)
114114
{
115115
if (!message.IsFault)
@@ -156,7 +156,7 @@ void ValidateMessageBody(ref System.ServiceModel.Channels.Message message, bool
156156

157157
As previously discussed, the exceptions thrown by the handler differ between the client and the service. On the service, the exceptions are derived from <xref:System.ServiceModel.FaultException>, on the client the exceptions are regular custom exceptions.
158158

159-
```
159+
```csharp
160160
void InspectionValidationHandler(object sender, ValidationEventArgs e)
161161
{
162162
if (e.Severity == XmlSeverityType.Error)
@@ -200,7 +200,7 @@ void ValidateMessageBody(ref System.ServiceModel.Channels.Message message, bool
200200

201201
The following `SchemaValidationBehavior` class is the behavior used to add this sample's message inspector to the client or dispatch runtime. The implementation is rather basic in both cases. In <xref:System.ServiceModel.Description.IEndpointBehavior.ApplyClientBehavior%2A> and <xref:System.ServiceModel.Description.IEndpointBehavior.ApplyDispatchBehavior%2A>, the message inspector is created and added to the <xref:System.ServiceModel.Dispatcher.ClientRuntime.MessageInspectors%2A> collection of the respective runtime.
202202

203-
```
203+
```csharp
204204
public class SchemaValidationBehavior : IEndpointBehavior
205205
{
206206
XmlSchemaSet schemaSet;
@@ -293,7 +293,7 @@ public class SchemaValidationBehavior : IEndpointBehavior
293293

294294
The overridden `CreateBehavior` method turns the configuration data into a behavior object when the runtime evaluates the configuration data as it builds a client or an endpoint.
295295

296-
```
296+
```csharp
297297
public class SchemaValidationBehaviorExtensionElement : BehaviorExtensionElement
298298
{
299299
public SchemaValidationBehaviorExtensionElement()
@@ -363,7 +363,7 @@ public bool ValidateRequest
363363
## Adding Message Inspectors Imperatively
364364
Except through attributes (which is not supported in this sample for the reason cited previously) and configuration, behaviors can quite easily be added to a client and service runtime using imperative code. In this sample, this is done in the client application to test the client message inspector. The `GenericClient` class is derived from <xref:System.ServiceModel.ClientBase%601>, which exposes the endpoint configuration to the user code. Before the client is implicitly opened the endpoint configuration can be changed, for instance by adding behaviors as shown in the following code. Adding the behavior on the service is largely equivalent to the client technique shown here and must be performed before the service host is opened.
365365

366-
```
366+
```csharp
367367
try
368368
{
369369
Console.WriteLine("*** Call 'Hello' with generic client, with client behavior");

docs/framework/wcf/samples/message-security-anonymous.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Console.ReadLine();
129129

130130
When you run the sample, the operation requests and responses are displayed in the client console window. Press ENTER in the client window to shut down the client.
131131

132-
```
132+
```console
133133
IsCallerAnonymous returned: True
134134
Add(100,15.99) = 115.99
135135
Subtract(145,76.54) = 68.46
@@ -162,7 +162,7 @@ Press <ENTER> to terminate client.
162162
163163
The following line copies the server certificate into the client trusted people store. This step is required because certificates generated by Makecert.exe are not implicitly trusted by the client system. If you already have a certificate that is rooted in a client trusted root certificate—for example, a Microsoft-issued certificate—this step of populating the client certificate store with the server certificate is not required.
164164
165-
```
165+
```console
166166
certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople
167167
```
168168

docs/framework/wcf/samples/message-security-certificate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ client.Close();
187187

188188
When you run the sample, the operation requests and responses are displayed in the client console window. Press ENTER in the client window to shut down the client.
189189

190-
```
190+
```console
191191
CN=client.com
192192
Add(100,15.99) = 115.99
193193
Subtract(145,76.54) = 68.46
@@ -240,7 +240,7 @@ Press <ENTER> to terminate client.
240240
241241
The following line copies the server certificate into the client trusted people store. This step is required because certificates generated by Makecert.exe are not implicitly trusted by the client system. If you already have a certificate that is rooted in a client trusted root certificate—for example, a Microsoft-issued certificate—this step of populating the client certificate store with the server certificate is not required.
242242
243-
```
243+
```console
244244
certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople
245245
```
246246

docs/framework/wcf/samples/message-security-over-message-queuing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public class OrderProcessorService : IOrderProcessor
265265

266266
When run, the service code displays the client identification. The following is a sample output from the service code:
267267

268-
```
268+
```console
269269
The service is ready.
270270
Press <ENTER> to terminate service.
271271

@@ -323,7 +323,7 @@ Processing Purchase Order: 6536e097-da96-4773-9da3-77bab4345b5d
323323
324324
The following line copies the server certificate into the client trusted people store. This step is required because certificates generated by Makecert.exe are not implicitly trusted by the client system. If you already have a certificate that is rooted in a client trusted root certificate—for example, a Microsoft-issued certificate—this step of populating the client certificate store with the server certificate is not required.
325325
326-
```
326+
```console
327327
certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople
328328
```
329329

docs/framework/wcf/samples/message-security-sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Console.WriteLine("Called by {0}", ServiceSecurityContext.Current.PrimaryIdentit
9696

9797
When you run the sample, the operation requests and responses are displayed in the client console window. Press ENTER in the client window to shut down the client.
9898

99-
```
99+
```console
100100
Add(100,15.99) = 115.99
101101
Subtract(145,76.54) = 68.46
102102
Multiply(9,81.25) = 731.25

docs/framework/wcf/samples/message-security-user-name.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ client.Close();
128128

129129
When you run the sample, the operation requests and responses are displayed in the client console window. Press ENTER in the client window to shut down the client.
130130

131-
```
131+
```console
132132
MyMachine\TestAccount
133133
Add(100,15.99) = 115.99
134134
Subtract(145,76.54) = 68.46
@@ -161,7 +161,7 @@ Press <ENTER> to terminate client.
161161
162162
The following line copies the server certificate into the client trusted people store. This step is required because certificates generated by Makecert.exe are not implicitly trusted by the client system. If you already have a certificate that is rooted in a client trusted root certificate—for example, a Microsoft-issued certificate—this step of populating the client certificate store with the server certificate is not required.
163163
164-
```
164+
```console
165165
certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople
166166
```
167167

docs/framework/wcf/samples/mtom-encoding.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This sample demonstrates the use of the Message Transmission Optimization Mechan
3636

3737
The contract chosen for this sample transmits binary data to the service and receives the number of bytes uploaded as the return value. When the service is installed and the client is run, it prints out the number 1000, which indicates that all 1000 bytes were received. The remainder of the output lists optimized and non-optimized message sizes for various payloads.
3838

39-
```
39+
```console
4040
Output:
4141
1000
4242
@@ -64,7 +64,7 @@ Press <ENTER> to terminate client.
6464

6565
1. Install ASP.NET 4.0 using the following command.
6666

67-
```
67+
```console
6868
%windir%\Microsoft.NET\Framework\v4.0.XXXXX\aspnet_regiis.exe /i /enable
6969
```
7070

docs/framework/wcf/samples/multiple-endpoints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void Main()
8181

8282
When you run the client, interactions with both endpoints are displayed.
8383

84-
```
84+
```console
8585
Communicate with basic endpoint.
8686
Add(100,15.99) = 115.99
8787
Subtract(145,76.54) = 68.46

docs/framework/wcf/samples/namedpipe-activation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Press <ENTER> to terminate client.
174174

175175
1. To support net.pipe activation, the default Web site must first be bound to the net.pipe protocol. This can be done using appcmd.exe, which is installed with the IIS 7.0 management toolset. From an elevated (administrator) command prompt, run the following command.
176176

177-
```
177+
```console
178178
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site"
179179
-+bindings.[protocol='net.pipe',bindingInformation='*']
180180
```
@@ -186,7 +186,7 @@ Press <ENTER> to terminate client.
186186

187187
2. Although all applications within a site share a common net.pipe binding, each application can enable net.pipe support individually. To enable net.pipe for the /servicemodelsamples application, run the following command from an elevated command prompt.
188188

189-
```
189+
```console
190190
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/servicemodelsamples" /enabledProtocols:http,net.pipe
191191
```
192192

@@ -203,7 +203,7 @@ Press <ENTER> to terminate client.
203203

204204
1. Remove net.tcp from the list of enabled protocols by running the following command from an elevated command prompt.
205205

206-
```
206+
```console
207207
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/servicemodelsamples" /enabledProtocols:http
208208
```
209209

@@ -212,7 +212,7 @@ Press <ENTER> to terminate client.
212212

213213
2. Remove the net.tcp site binding by running the following command from an elevated command prompt.
214214

215-
```
215+
```console
216216
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" --bindings.[protocol='net.pipe',bindingInformation='*']
217217
```
218218

0 commit comments

Comments
 (0)