WcfClient.Dynamic 8.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package WcfClient.Dynamic --version 8.0.1                
NuGet\Install-Package WcfClient.Dynamic -Version 8.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="WcfClient.Dynamic" Version="8.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WcfClient.Dynamic --version 8.0.1                
#r "nuget: WcfClient.Dynamic, 8.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 WcfClient.Dynamic as a Cake Addin
#addin nuget:?package=WcfClient.Dynamic&version=8.0.1

// Install WcfClient.Dynamic as a Cake Tool
#tool nuget:?package=WcfClient.Dynamic&version=8.0.1                

WcfClient.Dynamic

This package simplifies the process of consuming web endpoints of SOAP style, allowing dynamic (re)configuration of endpoint address, binding type, and all related data within appsettings. Incoming and outgoing messages, as well as other properties, can be configured using this package.

Installation

The package may be installed with the following commands:

  • Using the .NET CLI:

dotnet add package WcfClient.Dynamic --latest

  • Using NPM:

npm install WcfClient.Dynamic@latest

  • Using NuGet Package Manager Console:

Install-Package WcfClient.Dynamic

Configuration

In the startup.cs or in the program.cs class, add the following line of code to configure a WCF client for consuming the desired web service:

services.AddWcfGenericClient<WebServiceInterface, Settings>(configurationSectionName)

where Settings is a SoapSettings class or any other class that derives from it.

The configuration section in the appsettings file may take one of the following forms:

"ConfigurationSectionName": {
  "OutgoingMessageHeaders": {
    "Headers": [
      {
        "Key": "HeaderName",
        "Value": "HeaderValue",
        "Ns": "Namespace"
      }
    ]
  },
  "OutgoingMessageProperties": [
      {
        "Key": "CookieName",
        "Value": "CookieValue"
      }
    ],
  "SoapClient": {
    // Binding section here ...
    // ...
    "EndpointConfiguration": 1
  }
}

Note that OutgoingMessageHeaders and OutgoingMessageProperties sections are optional.

Allowed bindings

Each binding has these properties in common:

{
    "EndpointAddress": "https://{service-address}.asmx",
      "Name": "binding-name",
      "NamespaceIdentifier": "ns",
      "CloseTimeout": 60000,
      "OpenTimeout": 60000,
      "ReceiveTimeout": 60000,
      "SendTimeout": 60000
}

The following bindings may be declared in the "Binding" section:

  • BasicHttpsBinding:
"SoapHttpsBinding": {
    // Common binding properties not included here for the sake of simplicity and readability
    "AllowCookies": true,
    "BypassProxyOnLocal": true,
    "MaxBufferSize": null,
    "MaxBufferPoolSize": null,
    "MaxReceivedMessageSize": null,
    "TransferMode": null,
    "UseDefaultWebProxy": null,
    "HostNameComparisonMode": null,
    "BasicHttpsSecurityMode": 0,
    "WSMessageEncoding": 1
}

For more information, inspect the SoapHttpsBinding class.

  • BasicHttpBinding;
  • NetHttpBinding;
  • NetHttpsBinding;
  • NetNamedPipeBinding;
  • NetTcpBinding;
  • WSHttpBinding;
  • Ws2007HttpBinding;
  • WsFederationHttpBinding.

Usage

The WCF client may be injected into the specified service via:

  1. IGenericWcfClient<WebServiceInterface> wcfClient;
  2. Func<Settings, WcfClient<WebServiceInterface>> factoryMethod.

If you choose the second option, it will be necessary to inject the following lines into the constructor's declaration of your service implementation:

  • Func<WcfClient<WebServiceInterface>, OperationContextScope> scopeSelector;
  • IOptionsSnapshot<Settings> settings;

The consumption of the web service would look like this:

var result = await _wcfClient.CallAsync(x => 
{
    return x.Service.GetInfoAsync(new GetInfoRequest());
}

or

using (var client = _factoryMethod(_settings.Value))
{
    using (var scope = _scopeSelector(client))
    {
        // apply message's outgoing headers and properties here
        // ...

        return client.Service.GetInfoAsync(new GetInfoRequest());
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on WcfClient.Dynamic:

Package Downloads
WcfClient.Resilient

Provides a resilient WCF client as a web service reverse proxy built on top of GenericWcfClient, featuring support for Polly's retry actions and the circuit breaker pattern.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.2 108 10/14/2024
8.0.1 110 9/14/2024
8.0.0 121 5/18/2024
8.0.0-beta 103 5/8/2024
8.0.0-alpha 83 5/1/2024
6.0.1 75 11/5/2024
6.0.0 120 6/6/2024
5.0.1 80 11/8/2024
5.0.0 100 6/17/2024

Additional validity checks on applied binding configuration