WSDL into .NET core project

10,154

The problem is that your web service endpoint's WSDL uses a different way of storing the XML operation data. As Henk points out, using the wrapped flag when manually running the dotnet-svcutil tool is the solution here.

  1. Edit your .csproj file and add the following node inside the <ItemGroup> node:

<DotNetCliToolReference Include="dotnet-svcutil" Version="1.0.*" />

  1. Open up a PowerShell terminal from within the folder where the .csproj file resides.
  2. Run dotnet restore.
  3. Run dotnet svcutil https://smp.difi.no/ws/2.0?wsdl -wr.

The tool should now have generated the necessary artifacts inside ServiceReference1\Reference.cs.

enter image description here

Share:
10,154

Related videos on Youtube

Andrew
Author by

Andrew

Computer science student

Updated on June 04, 2022

Comments

  • Andrew
    Andrew almost 2 years

    I had worked before with WCF apps and there was no issue but now with this service I experienced some issues. I am not sure what is the reason behind but I cannot add https://smp.difi.no/ws/2.0?wsdl in my project.

    The error I am also getting is the following:

    Cannot import wsdl:port
    Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
    XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://service.elma.difi.no/']/wsdl:binding[@name='ElmaServiceImplServiceSoapBinding']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://service.elma.difi.no/']/wsdl:service[@name='ElmaServiceImplService']/wsdl:port[@name='ElmaServiceImplPort']
    Cannot import wsdl:binding
    Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
    XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='no:difi:elma:smp:webservice']/wsdl:portType[@name='difi']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://service.elma.difi.no/']/wsdl:binding[@name='ElmaServiceImplServiceSoapBinding']
    Cannot import wsdl:portType
    Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
    Error: These members may not be derived.
    XPath to Error Source: //wsdl:definitions[@targetNamespace='no:difi:elma:smp:webservice']/wsdl:portType[@name='difi']  
    

    Any idea what is going wrong here? Tried it from SoapUI and works fine but not from VS.

    • Henk Holterman
      Henk Holterman over 5 years
      Google Error: These members may not be derived. for some pointers.
    • Henk Holterman
      Henk Holterman over 5 years
      Using the not-core framework you can resolve this with /wrapped on the command line, VS seems to do that automatically.
    • Henk Holterman
      Henk Holterman over 5 years
      There are dotnet core commandline tools, but I have no experience using them.
  • Levi Fuller
    Levi Fuller over 4 years
    Unfortunately, if the underlying service is using SOAP 1.0 then you will still receive theses errors. The two options would be to update the service to be compatible with SOAP 1.1 standards or create a separate .NET Framework app and integrate with it.