Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TransportWithMessageCredential in dotnet-svcutil #3969

Closed
johnpenmanweb opened this issue Oct 16, 2019 · 26 comments
Closed

Support TransportWithMessageCredential in dotnet-svcutil #3969

johnpenmanweb opened this issue Oct 16, 2019 · 26 comments
Assignees
Labels
dotnet-svcutil This issue is regarding the dotnet-svcutil tool. tooling An issues related to any tool shipped from this repo.

Comments

@johnpenmanweb
Copy link

johnpenmanweb commented Oct 16, 2019

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...

@StephenBonikowsky
Copy link
Member

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

@dasetser
Copy link
Contributor

dasetser commented Nov 4, 2019

@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.

@StephenBonikowsky StephenBonikowsky added this to the Investigation milestone Nov 4, 2019
@se7vanj
Copy link

se7vanj commented Nov 20, 2019

@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.

@StephenBonikowsky StephenBonikowsky added the tooling An issues related to any tool shipped from this repo. label Dec 9, 2019
@StephenBonikowsky
Copy link
Member

@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.

@StephenBonikowsky StephenBonikowsky modified the milestones: Investigation, dotnet-svcutil 2.0.2, dotnet-svcutil 2.0.3 Dec 9, 2019
@OzBob
Copy link

OzBob commented Dec 19, 2019

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

  • Warning: Cannot import wsdl:binding
  • Warning: Cannot import wsdl:port

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?

@dasetser
Copy link
Contributor

@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.

@RealDotNetDave
Copy link

RealDotNetDave commented Jan 2, 2020

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?

@mconnew
Copy link
Member

mconnew commented Jan 2, 2020

@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?

@dasetser
Copy link
Contributor

dasetser commented Jan 2, 2020

@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).

@dasetser
Copy link
Contributor

dasetser commented Jan 6, 2020

@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.

@dasetser dasetser changed the title Cannot import wsdl:binding in .net core 2.2 (latest) Support TransportWithMessageCredential in dotnet-svcutil Jan 6, 2020
@RealDotNetDave
Copy link

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

@mconnew
Copy link
Member

mconnew commented Jan 7, 2020

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

@RealDotNetDave
Copy link

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.

@OzBob
Copy link

OzBob commented Jan 9, 2020

@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.

@StephenBonikowsky StephenBonikowsky added the dotnet-svcutil This issue is regarding the dotnet-svcutil tool. label Jan 22, 2020
@IgorLaktic
Copy link

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:
<sapattahnd:Enabled xmlns:sapattahnd='http://www.sap.com/710/features/attachment/'>..</sapattahnd:Enabled>

XPath://wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:binding[@name='BINDING_soap12']
Assertions:
<sapattahnd:Enabled xmlns:sapattahnd='http://www.sap.com/710/features/attachment/'>..</sapattahnd:Enabled>
<saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd='http://www.sap.com/webas/710/soap/features/transportbinding/'>..</saptrnbnd:OptimizedXMLTransfer>

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:
<sapattahnd:Enabled xmlns:sapattahnd='http://www.sap.com/710/features/attachment/'>..</sapattahnd:Enabled>

XPath://wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style']/wsdl:binding[@name='BINDING']
Assertions:
<sapattahnd:Enabled xmlns:sapattahnd='http://www.sap.com/710/features/attachment/'>..</sapattahnd:Enabled>
<saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd='http://www.sap.com/webas/710/soap/features/transportbinding/'>..</saptrnbnd:OptimizedXMLTransfer>

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']

@wh1sp3r
Copy link

wh1sp3r commented Feb 5, 2020

Same problem here with connecting to SAP as OP.

Any news on svcUtil 2.0.3 or timespan?

@StephenBonikowsky
Copy link
Member

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.

@0x1D-1983
Copy link

0x1D-1983 commented Feb 13, 2020

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

@0x1D-1983
Copy link

the endpoint in question has the following profile

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

@dasetser dasetser removed this from the dotnet-svcutil 2.0.3 milestone Mar 6, 2020
@dasetser dasetser added this to the dotnet-svcutil 2.0.4 milestone Mar 6, 2020
@dasetser
Copy link
Contributor

dasetser commented Mar 6, 2020

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.

@flacidsnake
Copy link

Is this related to #1257 ?

@ps-nk
Copy link

ps-nk commented Aug 3, 2020

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

I have the same problem / error as @IgorLaktic .

BR

@dasetser dasetser removed their assignment Aug 4, 2020
@dasetser
Copy link
Contributor

dasetser commented Aug 4, 2020

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

@imcarolwang
Copy link
Contributor

Closing as TransportWithMessageCredential security mode is supported in dotnet-svcutil 2.0.3 release.

@0x1D-1983
Copy link

it is still not supported or not all cases are supported, I just checked with NET6 and SvcUitl 2.0.3

{System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The message could not be processed. This is most likely because the action 'http://www.id3global.com/ID3gWS/2013/04/IGlobalAuthenticate/AuthenticateSP' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding. --- End of inner exception stack trace --- at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.Se…

@HongGit
Copy link
Contributor

HongGit commented Apr 13, 2022

Close as this is fixed. If the issue persists, feel free to re-open or open a new issue.

@HongGit HongGit closed this as completed Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-svcutil This issue is regarding the dotnet-svcutil tool. tooling An issues related to any tool shipped from this repo.
Projects
None yet
Development

No branches or pull requests