Audit.WCF.Client 27.2.0

dotnet add package Audit.WCF.Client --version 27.2.0                
NuGet\Install-Package Audit.WCF.Client -Version 27.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Audit.WCF.Client" Version="27.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Audit.WCF.Client --version 27.2.0                
#r "nuget: Audit.WCF.Client, 27.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Audit.WCF.Client as a Cake Addin
#addin nuget:?package=Audit.WCF.Client&version=27.2.0

// Install Audit.WCF.Client as a Cake Tool
#tool nuget:?package=Audit.WCF.Client&version=27.2.0                

Audit.WCF.Client

WCF client Audit Extension for Audit.NET library.

Generate Audit Logs for Windows Communication Foundation (WCF) service calls on client-side.

Audit.Wcf.Client provides the client-side infrastructure to log interactions with WCF services. It records detailed information of the service method calls by using an IClientMessageInspector to intercept the request and response messages.

If you are looking for server-side audit, please check the Audit.WCF library.

Install

NuGet Package

To install the package run the following command on the Package Manager Console:

PM> Install-Package Audit.Wcf.Client

NuGet Status NuGet Count

Usage

A custom endpoint behavior is provided to enable auditing on the requests and responses of the WCF service calls.

There are two ways to configure the endpoint behavior:

  • Adding the audit behavior to the client endpoint on the app.config / web.config of your client application.

    For example:

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
        <system.serviceModel>
      	<bindings>
      	  <basicHttpBinding>
      		<binding name="BasicHttpBinding_IService" />
      	  </basicHttpBinding>
      	</bindings>
      	<client>
      	  <endpoint address="http://localhost/Service.svc" binding="basicHttpBinding"
      		bindingConfiguration="BasicHttpBinding_IService" contract="MyServiceReference.IService" name="BasicHttpBinding_IService"
      		behaviorConfiguration="auditBehavior" />
      	</client>
      	<behaviors>
      	 <endpointBehaviors>
      	  <behavior name="auditBehavior">
      	   <auditBehavior includeResponseHeaders="true" eventType="Catalog:{action}" />
      	  </behavior>
      	 </endpointBehaviors>
      	</behaviors>
      	<extensions>
      	 <behaviorExtensions>
      	  <add name="auditBehavior"
      		 type="Audit.Wcf.Client.AuditBehavior, Audit.Wcf.Client, PublicKeyToken=571d6b80b242c87e"/>
      	 </behaviorExtensions>
      	</extensions>
        </system.serviceModel>
      </configuration>
    

    Note you have to include the behaviorConfiguration property on the client endpoint, the endpoint behavior auditBehavior, and the behavior extension pointing the provided type Audit.Wcf.Client.AuditBehavior from the assembly Audit.Wcf.Client

  • Adding the audit behavior on code when creating the channel.

    For example:

    public static IService GetServiceProxy()
    {
        var channelFactory = new ChannelFactory<IService>(new BasicHttpBinding(), new EndpointAddress(URL));
        channelFactory.Endpoint.EndpointBehaviors.Add(new AuditEndpointBehavior()
        {
          EventType = "Catalog:{action}",
          IncludeResponseHeaders = true
        });
        return channelFactory.CreateChannel();
    }
    

Configuration

The Audit Behavior can be configured with the following properties:

  • EventType: A string that identifies the event type. Default is "{action}".
  • Can contain the following placeholders:
    • {action}: Replaced with the action URL
  • IncludeRequestHeaders: Boolean value that indicates whether the output should include the request headers. Default is false.
  • IncludeResponseHeaders: Boolean value that indicates whether the output should include the response headers. Default is false.
  • AuditDataProvider: Allows to set a specific audit data provider. By default the globally configured data provider is used. See Audit.NET Data Providers section for more information.
  • AuditScopeFactory: Allows to set a specific audit scope factory. By default the globally configured AuditScopeFactory is used.

Output mechanism

To globally configure the output mechanism, use the Audit.Core.Configuration class to set a Data Provider. For more details please see Event Output Configuration.

For example:

Audit.Core.Configuration.Setup()
	.UseFileLogProvider(config => config.Directory(@"C:\Logs"));

This should be done prior to the AuditScope creation, i.e. during application startup.

Output

Audit.Wcf.Client output includes:

  • Execution time and duration
  • Environment information such as user, machine, domain and locale.
  • Request body
  • Response body
  • Http Status Code
  • Request headers (optional)
  • Response headers (optional)

Output details

The following table describes the Audit.Wcf.Client output fields:

Describes an audited WCF client event

Field Name Type Description
Action string The requested action URL
RequestBody string The request body (XML)
RequestHeaders Dictionary<string, string> The request HTTP headers (optional)
HttpMethod string The HTTP method used (POST, PUT)
ResponseAction string The response action (if any)
MessageId string The message ID (if any)
ResponseStatusCode HttpStatusCode The response HTTP status code
ResponseBody string The response body (XML)
ResponseHeaders Dictionary<string, string> The response HTTP headers (optional)
IsFault string Value that indicates whether the message generated any SOAP faults.

Output Sample

{
    "EventType": "Catalog:http://tempuri.org/IService/GetProductDetails",
    "WcfClientEvent": {
        "Action": "http://tempuri.org/IService/GetProductDetails",
        "RequestBody": "<s:Envelope> ... </s:Envelope>",
        "HttpMethod": "POST",
        "ResponseAction": null,
        "MessageId": null,
        "ResponseStatuscode": 200,
        "ResponseBody": "<s:Envelope> ... </s:Envelope>",
        "ResponseHeaders": {
            "Content-Length": "431",
            "Cache-Control": "private",
            "Content-Type": "text/xml; charset=utf-8",
            "Date": "Thu, 29 Jul 2021 23",
            "Server": "Microsoft-IIS/10.0",
            "X-AspNet-Version": "4.0.30319",
            "X-Powered-By": "ASP.NET"
        },
        "IsFault": false
    },
    "Environment": {
        "UserName": "Federico",
        "MachineName": "DESKTOP",
        "DomainName": "DESKTOP",
        "CallingMethodName": "WcfClient.MyServiceReference.ServiceClient.GetProductDetails()",
        "AssemblyName": "WcfClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
        "Culture": "en-US"
    },
    "StartDate": "2021-07-29T23:31:10.9631278Z",
    "EndDate": "2021-07-29T23:31:11.0641269Z",
    "Duration": 101
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
27.2.0 72 11/23/2024
27.1.1 78 10/28/2024
27.1.0 76 10/24/2024
27.0.3 151 9/25/2024
27.0.2 94 9/19/2024
27.0.1 99 9/4/2024
27.0.0 105 9/3/2024
26.0.1 124 8/22/2024
26.0.0 94 7/19/2024
25.0.7 129 7/4/2024
25.0.6 98 6/24/2024
25.0.5 98 6/18/2024
25.0.4 131 3/24/2024
25.0.3 266 3/13/2024
25.0.2 98 3/12/2024
25.0.1 114 2/28/2024
25.0.0 114 2/16/2024
24.0.1 121 2/12/2024
24.0.0 126 2/12/2024
23.0.0 190 12/14/2023
22.1.0 155 12/9/2023
22.0.2 165 12/1/2023
22.0.1 1,088 11/16/2023
22.0.0 153 11/14/2023
21.1.0 173 10/9/2023
21.0.4 187 9/15/2023
21.0.3 1,398 7/9/2023
21.0.2 191 7/6/2023
21.0.1 187 5/27/2023
21.0.0 1,960 4/15/2023
20.2.4 532 3/27/2023
20.2.3 437 3/17/2023
20.2.2 233 3/14/2023
20.2.1 268 3/11/2023
20.2.0 279 3/7/2023
20.1.6 313 2/23/2023
20.1.5 293 2/9/2023
20.1.4 348 1/28/2023
20.1.3 323 12/21/2022
20.1.2 348 12/14/2022
20.1.1 356 12/12/2022
20.1.0 356 12/4/2022
20.0.4 365 11/30/2022
20.0.3 438 10/28/2022
20.0.2 426 10/26/2022
20.0.1 471 10/21/2022
20.0.0 462 10/1/2022
19.4.1 472 9/10/2022
19.4.0 483 9/2/2022
19.3.0 479 8/23/2022
19.2.2 489 8/11/2022
19.2.1 1,294 8/6/2022
19.2.0 465 7/24/2022
19.1.4 2,918 5/23/2022
19.1.3 485 5/22/2022
19.1.2 510 5/18/2022
19.1.1 517 4/28/2022
19.1.0 514 4/10/2022
19.0.7 746 3/13/2022
19.0.6 506 3/7/2022
19.0.5 525 1/28/2022
19.0.4 532 1/23/2022
19.0.3 366 12/14/2021
19.0.2 370 12/11/2021
19.0.1 736 11/20/2021
19.0.0 400 11/11/2021
19.0.0-rc.net60.2 154 9/26/2021
19.0.0-rc.net60.1 207 9/16/2021
18.1.6 445 9/26/2021
18.1.5 456 9/7/2021
18.1.4 437 9/6/2021
18.1.3 426 8/19/2021
18.1.2 481 8/8/2021
18.1.1 426 8/5/2021
18.1.0 656 8/1/2021
18.0.1 468 7/30/2021