Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WSDL into .NET core project

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.

like image 460
Andrew Avatar asked Dec 18 '25 17:12

Andrew


1 Answers

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

like image 96
silkfire Avatar answered Dec 20 '25 06:12

silkfire



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!