我正在开发一个调用WSDL SOAP API的小型Web API。WSDL文件已经设置了端点,但我希望能够在appsettings.json文件中更改它,以便我可以为不同的环境(DEV、Production等)使用不同的端点。我知道在传统的.NET中,您可以在web.config文件中设置端点,因此我尝试在appsettings.json中模拟它。
"client": {
"endpoint": {
"address": "https://testaddress.com:9000",
"binding": "basicHttpBinding",
"bindingConfiguration": "MyWSDLService_Binder",
"contract": "MyWSDLNamespace.Service__PortType",
"name": "MyWSDLService_Port"
}
}
我将bindingConfiguration
设置为实际WSDL中<wsdl:binding>
节点中的name
属性,将contract
设置为与WCF命名空间前缀相同的该节点的type
。 我将name:
设置为<wsdl:port>
节点的name
属性。基本上,我想能够在appsettings.json文件中设置<soap:address location>
。