WcfClient.Dynamic 8.0.0-beta

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

// Install WcfClient.Dynamic as a Cake Tool
#tool nuget:?package=WcfClient.Dynamic&version=8.0.0-beta&prerelease

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": {
    "Headers": [
      {
        "Key": "PropertyName",
        "Value": "PropertyName",
        "Ns": "Namespace"
      }
    ]
  },
  "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 outcomming 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

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
8.0.0 39 5/18/2024
8.0.0-beta 46 5/8/2024
8.0.0-alpha 28 5/1/2024