WcfClient.Dynamic
8.0.2
dotnet add package WcfClient.Dynamic --version 8.0.2
NuGet\Install-Package WcfClient.Dynamic -Version 8.0.2
<PackageReference Include="WcfClient.Dynamic" Version="8.0.2" />
paket add WcfClient.Dynamic --version 8.0.2
#r "nuget: WcfClient.Dynamic, 8.0.2"
// Install WcfClient.Dynamic as a Cake Addin #addin nuget:?package=WcfClient.Dynamic&version=8.0.2 // Install WcfClient.Dynamic as a Cake Tool #tool nuget:?package=WcfClient.Dynamic&version=8.0.2
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:
IGenericWcfClient<WebServiceInterface> wcfClient
;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 | Versions 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. |
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- SafeAgainst (>= 8.0.1)
- WcfClient.Settings (>= 8.0.0)
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 | 104 | 10/14/2024 |
8.0.1 | 108 | 9/14/2024 |
8.0.0 | 119 | 5/18/2024 |
8.0.0-beta | 101 | 5/8/2024 |
8.0.0-alpha | 81 | 5/1/2024 |
6.0.1 | 71 | 11/5/2024 |
6.0.0 | 118 | 6/6/2024 |
5.0.1 | 70 | 11/8/2024 |
5.0.0 | 98 | 6/17/2024 |
Prevented socket exhaustion