Audit.WCF.Client 27.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Audit.WCF.Client --version 27.0.3                
NuGet\Install-Package Audit.WCF.Client -Version 27.0.3                
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.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Audit.WCF.Client --version 27.0.3                
#r "nuget: Audit.WCF.Client, 27.0.3"                
#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.0.3

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

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.3.2 78 12/11/2024
27.3.1 74 12/10/2024
27.3.0 79 12/8/2024
27.2.0 93 11/23/2024
27.1.1 86 10/28/2024
27.1.0 86 10/24/2024
27.0.3 162 9/25/2024
27.0.2 100 9/19/2024
27.0.1 107 9/4/2024
27.0.0 113 9/3/2024
26.0.1 130 8/22/2024
26.0.0 101 7/19/2024
25.0.7 135 7/4/2024
25.0.6 104 6/24/2024
25.0.5 105 6/18/2024
25.0.4 135 3/24/2024
25.0.3 270 3/13/2024
25.0.2 102 3/12/2024
25.0.1 118 2/28/2024
25.0.0 118 2/16/2024
24.0.1 131 2/12/2024
24.0.0 134 2/12/2024
23.0.0 194 12/14/2023
22.1.0 159 12/9/2023
22.0.2 169 12/1/2023
22.0.1 1,115 11/16/2023
22.0.0 157 11/14/2023
21.1.0 177 10/9/2023
21.0.4 191 9/15/2023
21.0.3 1,480 7/9/2023
21.0.2 195 7/6/2023
21.0.1 191 5/27/2023
21.0.0 1,964 4/15/2023
20.2.4 536 3/27/2023
20.2.3 442 3/17/2023
20.2.2 237 3/14/2023
20.2.1 272 3/11/2023
20.2.0 283 3/7/2023
20.1.6 317 2/23/2023
20.1.5 297 2/9/2023
20.1.4 352 1/28/2023
20.1.3 327 12/21/2022
20.1.2 352 12/14/2022
20.1.1 360 12/12/2022
20.1.0 362 12/4/2022
20.0.4 371 11/30/2022
20.0.3 444 10/28/2022
20.0.2 432 10/26/2022
20.0.1 477 10/21/2022
20.0.0 468 10/1/2022
19.4.1 478 9/10/2022
19.4.0 489 9/2/2022
19.3.0 485 8/23/2022
19.2.2 495 8/11/2022
19.2.1 1,346 8/6/2022
19.2.0 471 7/24/2022
19.1.4 3,066 5/23/2022
19.1.3 491 5/22/2022
19.1.2 516 5/18/2022
19.1.1 523 4/28/2022
19.1.0 520 4/10/2022
19.0.7 899 3/13/2022
19.0.6 512 3/7/2022
19.0.5 534 1/28/2022
19.0.4 538 1/23/2022
19.0.3 372 12/14/2021
19.0.2 376 12/11/2021
19.0.1 742 11/20/2021
19.0.0 406 11/11/2021
19.0.0-rc.net60.2 156 9/26/2021
19.0.0-rc.net60.1 209 9/16/2021
18.1.6 451 9/26/2021
18.1.5 462 9/7/2021
18.1.4 443 9/6/2021
18.1.3 432 8/19/2021
18.1.2 487 8/8/2021
18.1.1 433 8/5/2021
18.1.0 662 8/1/2021
18.0.1 474 7/30/2021