我有 Dot Net Framework 3.5 Web 服務:http ://www.dneonline.com/calculator.asmx 我想在 dot Net Core(3 或 6,任何版本)上使用它。
當我運行程式時,它拋出例外:PlatformNotSupportedException:不支持組態檔
從任何 Dot Net Core 應用程式呼叫 WCF Dot Net Framework 3.5 在技術上是否可行?
參考: https ://medium.com/compendium/integrating-with-soap-web-services-in-net-core-adebfad173fb https://howtodomssqlcsharpexcelaccess.blogspot.com/2019/06/mvc-consume-web-service -service.html
uj5u.com熱心網友回復:
我在http://www.dneonline.com/calculator.asmx遇到了同樣的錯誤。我如何解決它是通過添加到建構式
CalculatorSoapClient.EndpointConfiguration.CalculatorSoap
或者
CalculatorSoapClient.EndpointConfiguration.CalculatorSoap12
IE
public static int add(int x, int y){
CalculatorSoapClient client = new CalculatorSoapClient(CalculatorSoapClient.EndpointConfiguration.CalculatorSoap);
return client.Add(x, y);
}
我應該補充一點,我沒有按照這里Reference.cs的建議進行編輯!
uj5u.com熱心網友回復:
我的導師給了我一篇文章,提供了答案。Khalidabuhakmeh 先生很好地解釋了如何在 .NET Core 中使用 SOAP API;謝謝你!
總結他們的步驟:
檢查您是否安裝了 .NET Core 2.1;如果沒有,請從 Microsoft 下載并安裝.
打開 Visual Studio 2019 或 Visual Studio 2022。
- 創建 .NET Core 控制臺應用程式。
- 轉到查看,然后單擊終端。
- 在終端輸入:
dotnet new tool-manifest
在終端輸入:
dotnet tool install dotnet-svcutil在終端輸入:
dotnet dotnet-svcutil https://www.dataaccess.com/webservicesserver/TextCasing.wso
如果您有同步操作并且確實有同步操作,那么:
在終端輸入:-- sync
dotnet dotnet-svcutil https://www.dataaccess.com/webservicesserver/TextCasing.wso --sync更多資訊
或者
輸入另一個 WSDL 鏈接:
dotnet dotnet-svcutil <wsdl url>使用 SOAP:
static async Task Main(string[] args) { var client = new TextCasingSoapTypeClient( TextCasingSoapTypeClient.EndpointConfiguration.TextCasingSoap, "https://www.dataaccess.com/webservicesserver/TextCasing.wso"); var result = await client.AllLowercaseWithTokenAsync("THIS IS A STRING", ""); // result: this is a string var value = result.Body.AllLowercaseWithTokenResult; Console.WriteLine(value); }
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/512558.html
上一篇:如何在Python中更改XmlDictionaryReaderQuotas上的MaxBytesPerRead屬性?
