Wcf: Support TransportWithMessageCredential in dotnet-svcutil

Created on 16 Oct 2019  路  23Comments  路  Source: dotnet/wcf

Not sure if this is related to #8 or not but I am getting an issue when trying to add wsdl's from SAP. Wsdl works in .Net Framework 4.6 but fails in .net core 2.2.
Below is the verbose of dotnet-svcutil:

Warning: The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:portType[@name='Z_RFC_VALIDATE_ADDRESS']
Warning: The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:portType[@name='Z_RFC_VALIDATE_ADDRESS']/wsdl:operation[@name='ZRfcValidateAddress']
Warning: Cannot import wsdl:binding
Detail: An exception was thrown in a call to a policy import extension.
Extension: System.ServiceModel.Channels.SecurityBindingElementImporter
Error: The method or operation is not implemented.
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:binding[@name='Z_RFC_VALIDATE_ADDRESS']
Warning: Cannot import wsdl:port
Detail:
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:service[@name='Z_RFC_VALIDATE_ADDRESS']/wsdl:port[@name='Z_RFC_VALIDATE_ADDRESS']
Warning: No endpoints compatible with .Net Core apps were found.
[28032.222] Time elapsed: 00:00:21.1325156
[28032.355] Processing Code DOM ...
Generating files...

dotnet-svcutil tooling

Most helpful comment

Dotnet-svcutil 2.0.3 release is focused on an open source effort. This will be included in dotnet-svcutil 2.0.4, which will be released as soon as we can afterwards.

All 23 comments

@johnpenmanweb We believe this is a known issue, @dasetser has the details, Daniel could you provide the information regarding this issue?

@johnpenmanweb Can you provide the wsdl for this service? From the output it looks like we can't find any endpoints that we think are compatible with .NET Core. We also output a warning that we can't import a binding because when importing a SecurityBindingElement we run into something that isn't implemented. It would be helpful to know what the binding looks like.

You mention that it may be related to the TransportWithMessageCredential issue, are you trying to use a service that uses this security mode? It's part of the runtime code, but we're still looking into what is needed to support generating a proxy with dotnet-svcutil for services that are using it.

@johnpenmanweb Can you provide the wsdl for this service? From the output it looks like we can't find any endpoints that we think are compatible with .NET Core. We also output a warning that we can't import a binding because when importing a SecurityBindingElement we run into something that isn't implemented. It would be helpful to know what the binding looks like.

You mention that it may be related to the TransportWithMessageCredential issue, are you trying to use a service that uses this security mode? It's part of the runtime code, but we're still looking into what is needed to support generating a proxy with dotnet-svcutil for services that are using it.

I am also facing the same issue, we have an existing webservice that asks for WSSE security policy (wsse:UsernameToken) on it, when trying to add it as a ServiceReference, on dotnet 3.1.100-preview3-014645, it throws below error:

Importing web service metadata ... Number of service endpoints found: 1 Scaffolding service reference code ... Warning:Warning: The following Policy Assertions were not Imported: XPath://wsdl:definitions[@targetNamespace='http://x.net/Agreement/z/za/20140601']/wsdl:binding[@name='y_20140601_SOAPbinding']/wsdl:operation[@name='Operation1'] Assertions: <wsam:Addressing xmlns:wsam='http://www.w3.org/2007/05/addressing/metadata'>..</wsam:Addressing> XPath://wsdl:definitions[@targetNamespace='http://x.net/Agreement/z/za/20140601']/wsdl:binding[@name='y_20140601_SOAPbinding']/wsdl:operation[@name='Operation2'] Warning:Warning: Unsupported binding element type: 'System.ServiceModel.Channels.UnrecognizedAssertionsBindingElement'. Warning:Warning: Endpoint 'PolicyTransaction_Devsoap12https' at address 'https://x/xa/xa/1.10' contains one or more bindings not compatible with .Net Core apps, skipping... Warning:Warning: **No endpoints compatible with .Net Core apps were found.** Updating project ... Done.

@se7vanj Thanks for the additional information. We have identified the problem and will be working on a fix for the tooling in an upcoming release.

I have a similar problem but using the VS 2019 Preview WCF ... Provider wizard, which generates code with the warnings in #2933 :

Many Build Errors like:

  • The type or namespace name 'ServiceContractAttributeAttribute' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?)

Do I need to add a dependency on Microsoft.Windows.Compatibility?

Would you like the publicly available WSDL definition that I used?

@OzBob Yes, if you can provide the WSDL that would be helpful. Feel free to send it to me in an email (dasetser at microsoft.com) if you would prefer not to post it here.

I'm having an issue too. My project was building fine, but all of a sudden I get over 3K of violations like this:

Error CS0234 The type or namespace name 'ServiceContractAttributeAttribute' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?) VerizonConnect.InstallationServices.Salesforce C:\src\Temp\nwf-install-svc-master\src\VerizonConnect.InstallationServices.Salesforce\SalesForceService.cs

I'm using VS2019 with .NET Core 3.1.

Any ideas?

@RealDotNetDave, that's unrelated. You are having a compilation reference problem. When applying an attribute, you don't need to provide the full attribute type name. You can optionally choose to exclude the suffix Attribubte. The generated code does include it and specifies the full namespace, so applies the attribute [System.ServiceModel.ServiceContractAttribute] to the generated interface. When the c# compiler is compiling the interface, it looks for the type System.ServiceModel.ServiceContractAttribute in each of the supplied assembly references. It can't find it, so then the compiler tries to apply the suffix Attribute to the attribute name, so looks for System.ServiceModel.ServiceContractAttributeAttribute. The problem is the compiler can't find the System.ServiceModel.Primitives reference assembly. You might have accidentally removed this from your .csproj or had a problem with the restore step. Do you get any errors when running dotnet restore for your project?

@RealDotNetDave In addition to Matt's comment it's possible the tool failed to add the System.ServiceModel.* package references to your project when it ran. If that is the case please open a new issue and include information about whether it fails in your environment even on a default .NET Core console app or if it's specific to your csproj (and if it's specific to your csproj it would help if you could narrow down what's causing the problem or provide the file so we can take a look).

@RealDotNetDave FYI I followed up with @OzBob through email. For him the restore was running into problems because of a nuget source that was failing (in his case the Windows Template Studio source). The workaround was to disabled all nuget package sources except nuget.org, then the restore and build succeeded.

This is unrelated to the initial issue reported by @johnpenmanweb, so to not distract from this thread any further please open a new issue if you need any more help with this.

After looking at a wsdl provided for the original issue I believe this is due to the dotnet-svcutil tool not supporting TransportWithMessageCredential, which was added to WCF Core in 3.0. I've modified the title of this issue to be specific to that, and we'll investigate what's needed for it to support this.

Thanks for the info. I don't use the wizard in Visual Studio since I can't configure the namespace or the output file for the service proxy. Instead, I use dotnet-svcutil.

So I created a blank project and used the Wizard to figure out the references. I just want to verify that these are the required packages:

System.ServiceModel.Duplex
System.ServiceModel.Http
System.ServiceModel.NetTcp
System.ServiceModel.Security

Thanks,
David

You are missing System.ServiceModel.Primitives from your list.

It does build fine without Primitives. Should I include it anyway?

What is really strange is that I could not build this project without those for packages, but someone else on my team could build it.

@RealDotNetDave @mconnew the Primitives is a dependency of the Http package (and others), nuget should be downloading it without an explicit project reference,

https://www.nuget.org/packages/System.ServiceModel.Http/
.NETStandard 2.0 dependencies are:
System.Private.ServiceModel (>= 4.7.0)
System.ServiceModel.Primitives (>= 4.7.0)

When I run my Test project Primitives and Http etc DLLs are in the \bin\Debug\netcoreapp3.1\ folder.

I am trying to connect SAP web service in Blazor Core 3.1 app by Microsoft WCF Web Service Reference Provider.
I am using all last versions. VS 2019 preview 2 , Core 3.1 etc..
In win app where is .NET ,same WSDL provide correct web service.
How to add SAP web service in Blazor Core 3.1 server side app?

Here is error:
The following Policy Assertions were not Imported:
XPath://wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:binding[@name='BINDING_soap12']
Assertions:
..

XPath://wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:binding[@name='BINDING_soap12']
Assertions:
..
..

The following Policy Assertions were not Imported:
XPath://wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:binding[@name='BINDING']
Assertions:
..

XPath://wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:binding[@name='BINDING']
Assertions:
..
..

The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:portType[@name='ZMWS']/wsdl:operation[@name='ZMwsGetOrder']
The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:portType[@name='ZMWS']/wsdl:operation[@name='ZMwsGetOrderList']
The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:portType[@name='ZMWS']/wsdl:operation[@name='ZMwsGetProducts']
The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:portType[@name='ZMWS']/wsdl:operation[@name='ZMwsGetWarehouses']
The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:portType[@name='ZMWS']

Same problem here with connecting to SAP as OP.

Any news on svcUtil 2.0.3 or timespan?

The 2.0.3 release is coming very soon. We are working on a last few items and plan on working on packaging and publishing by the end of the month.

I think I have a problem that is related to this issue. I'm trying to add the following service to a .net core 3.1 project (with latest ServiceModel Nuget packages: 4.7.0) but one of the endpoint bindings is failing to be imported:
https://id3global.com/ID3gWS/ID3global.svc?wsdl






It works fine in .NetFramework 4.7.2

the endpoint in question has the following profile

<binding name="wsHttpBinding_GlobalAuthenticate"> <security mode="TransportWithMessageCredential"> <transport clientCredentialType="None" /> <message clientCredentialType="UserName" /> </security> </binding>

Dotnet-svcutil 2.0.3 release is focused on an open source effort. This will be included in dotnet-svcutil 2.0.4, which will be released as soon as we can afterwards.

Is this related to #1257 ?

Hello @dasetser,
can you say when 2.0.4 will be released?

I have the same problem / error as @IgorLaktic .

BR

@HongGit would have a better idea than me on the timeline for future releases.

Was this page helpful?
0 / 5 - 0 ratings