Calling a SOAP service in .net Core

前端 未结 7 1925
失恋的感觉
失恋的感觉 2020-11-28 07:12

I´m porting a .net 4.6.2 code to a .net Core project, that calls a SOAP service. In the new code I´m using C# (because of some config reasons I just can´t r

7条回答
  •  情话喂你
    2020-11-28 08:05

    To consume a SOAP service from .NET core, adding connected service from the project UI does not work.

    Option 1: Use dotnet-svcutil CLI. Prerequisite: VS 2017, Version 15.5 or above

    1. Launch Developer Command Prompt VS 2017.
    2. Go to app.csproj file and add below references:

      
      
      
      
      
      
      
      
    3. Rebuild solution.

    4. Change directory to your project location from VS command prompt.
    5. run command: svcutil SOAP_URL?wsdl ; example: example.com/test/testing?wsdl This will generate reference files and output.config file in your project.
    6. .Net Core does not have any app.config or web.config files, but the output.config file will serve the SOAP binding.

    Option 2 In case you need to refer more than one SOAP sevice,

    1. Create a new class library project, use .Net framework 4.5.1 .Net framework matters as i saw the reference files generated from contract is not correct if .Net Framework is latest.
    2. Add service reference by right click on References.
    3. Refer the class library project from your .Net core project.

提交回复
热议问题