I am working on a small web API that calls a WSDL soap api. The WSDL file has an endpoint set, but I would like to be able to change that in the appsetting.json file so I can have different endpoints for different environments (DEV, Production, etc.) I know in traditional .NET you could set the endpoints in the web.config file, so I tried to emulate that in the appsettings.json
"client": {
"endpoint": {
"address": "https://testaddress.com:9000",
"binding": "basicHttpBinding",
"bindingConfiguration": "MyWSDLService_Binder",
"contract": "MyWSDLNamespace.Service__PortType",
"name": "MyWSDLService_Port"
}
}
I set the bindingConfiguration
to the name
attribute in the node <wsdl:binding>
in the actual WSDL and the contract
to the type
of that same node with the namespace of the WCF dot notated in front. The name:
I set to the name
attribute of the <wsdl:port>
node. Essentially I want to be able to set <soap:address location>
in the appsettings.json file.
Applications with WCF dependencies can be updated to use CoreWCF in-place on . NET framework, which then will work the same when updated to use . NET Core or . NET 5+.
The service configuration has been modified to define two endpoints that support the ICalculator contract, but each at a different address using a different binding.
As demonstrated in the Multiple Endpoints sample, a service can host multiple endpoints, each with different addresses and possibly also different bindings. This sample shows that it is possible to host multiple endpoints at the same address.
Endpoints provide clients access to the functionality offered by a WCF service. Each endpoint consists of four properties: An address that indicates where the endpoint can be found. A binding that specifies how a client can communicate with the endpoint. A contract that identifies the operations available.
Base on this link, in ASP.NET Core, it is no yet possible to do configuration in separate configuration files. It's set just from code.
Unfortunately you have to stick with code for the moment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With