Audit.WCF.Client 25.0.1

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

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

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.

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
25.0.4 99 3/24/2024
25.0.3 171 3/13/2024
25.0.2 69 3/12/2024
25.0.1 86 2/28/2024
25.0.0 84 2/16/2024
24.0.1 94 2/12/2024
24.0.0 96 2/12/2024
23.0.0 165 12/14/2023
22.1.0 125 12/9/2023
22.0.2 139 12/1/2023
22.0.1 850 11/16/2023
22.0.0 122 11/14/2023
21.1.0 140 10/9/2023
21.0.4 158 9/15/2023
21.0.3 1,083 7/9/2023
21.0.2 167 7/6/2023
21.0.1 161 5/27/2023
21.0.0 1,931 4/15/2023
20.2.4 503 3/27/2023
20.2.3 428 3/17/2023
20.2.2 209 3/14/2023
20.2.1 258 3/11/2023
20.2.0 257 3/7/2023
20.1.6 282 2/23/2023
20.1.5 280 2/9/2023
20.1.4 321 1/28/2023
20.1.3 295 12/21/2022
20.1.2 322 12/14/2022
20.1.1 331 12/12/2022
20.1.0 326 12/4/2022
20.0.4 336 11/30/2022
20.0.3 412 10/28/2022
20.0.2 404 10/26/2022
20.0.1 445 10/21/2022
20.0.0 436 10/1/2022
19.4.1 445 9/10/2022
19.4.0 453 9/2/2022
19.3.0 465 8/23/2022
19.2.2 462 8/11/2022
19.2.1 837 8/6/2022
19.2.0 441 7/24/2022
19.1.4 1,515 5/23/2022
19.1.3 459 5/22/2022
19.1.2 481 5/18/2022
19.1.1 490 4/28/2022
19.1.0 488 4/10/2022
19.0.7 470 3/13/2022
19.0.6 479 3/7/2022
19.0.5 511 1/28/2022
19.0.4 508 1/23/2022
19.0.3 345 12/14/2021
19.0.2 360 12/11/2021
19.0.1 707 11/20/2021
19.0.0 373 11/11/2021
19.0.0-rc.net60.2 144 9/26/2021
19.0.0-rc.net60.1 196 9/16/2021
18.1.6 420 9/26/2021
18.1.5 429 9/7/2021
18.1.4 413 9/6/2021
18.1.3 396 8/19/2021
18.1.2 454 8/8/2021
18.1.1 403 8/5/2021
18.1.0 625 8/1/2021
18.0.1 436 7/30/2021