WcfClient.Dynamic
8.0.0-alpha
See the version list below for details.
dotnet add package WcfClient.Dynamic --version 8.0.0-alpha
NuGet\Install-Package WcfClient.Dynamic -Version 8.0.0-alpha
<PackageReference Include="WcfClient.Dynamic" Version="8.0.0-alpha" />
paket add WcfClient.Dynamic --version 8.0.0-alpha
#r "nuget: WcfClient.Dynamic, 8.0.0-alpha"
// Install WcfClient.Dynamic as a Cake Addin #addin nuget:?package=WcfClient.Dynamic&version=8.0.0-alpha&prerelease // Install WcfClient.Dynamic as a Cake Tool #tool nuget:?package=WcfClient.Dynamic&version=8.0.0-alpha&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
Package Manager
:
NuGet\Install-Package WcfClient.Dynamic --latest
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"
}
]
},
"IncomingMessageHeaders": {
"Headers": [
{
"Key": "HeaderName",
"Value": "HeaderValue",
"Ns": "Namespace"
}
]
},
"IncomingMessageProperties": {
"Headers": [
{
"Key": "PropertyName",
"Value": "PropertyValue",
"Ns": "Namespace"
}
]
},
"SoapClient": {
// Binding section here ...
// ...
"EndpointConfiguration": 1
}
}
Note that OutgoingMessageHeaders
, OutgoingMessageProperties
, IncomingMessageHeaders
and IncomingMessageProperties
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 incomming/outcomming headers/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.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- WcfClient.Settings (>= 8.0.0-alpha)
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 | 118 | 10/14/2024 |
8.0.1 | 115 | 9/14/2024 |
8.0.0 | 126 | 5/18/2024 |
8.0.0-beta | 106 | 5/8/2024 |
8.0.0-alpha | 84 | 5/1/2024 |
6.0.1 | 85 | 11/5/2024 |
6.0.0 | 127 | 6/6/2024 |
5.0.1 | 106 | 11/8/2024 |
5.0.0 | 105 | 6/17/2024 |