dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.7k stars 558 forks source link

App.config '<system.serviceModel>' equivalent in ASPCore #2259

Closed inlineHamed closed 6 years ago

inlineHamed commented 7 years ago

I want to add a wsdl service to my ASP Core 1.1 app First I used 'Microsoft WCF Web Service Reference Provider' Extension but got an error that I described it here: https://github.com/dotnet/wcf/issues/2258

But as a alternative solution I tried to use 'SvcUtil.exe' and successfully generated a .cs file and also a output.config file.

For simplifying the problem first I tried to use these files in a DotNetFramework Console App: after adding .cs file I got lot's of errors due to missing of nuget packages. after searching I added missing nuget packages and also added the output.config content to the App.config and finally successfully connected to that service.

Then I tried this solution for a DotNetCore Console App: I added missing nuget packages but there is no App.config file in DotNetCore apps so was not able to use the config file. Then I run the app and got this error while calling the service: System.PlatformNotSupportedException: 'Configuration files are not supported.'

Is there any alternative way to config service model for dot net core apps?

inlineHamed commented 7 years ago

This is the output.config file that is generated by SvcUtil.exe: image

hongdai commented 7 years ago

@hmdhasani Dotcore is code based currently. It's not possible to configure it via a configuration file.

inlineHamed commented 7 years ago

@hongdai Is there any way to turn the configuration as code?

hongdai commented 7 years ago

@hmdhasani Yes, there is an extension point that you can add code to configure the client behavior. Please take a look at the blog: https://blogs.msdn.microsoft.com/webdev/2017/06/28/wcf-web-service-reference-mex-authentication.

WeihanLi commented 6 years ago

@hongdai hi, I met the same problem.Is there any method possible to configure it via a configuration file now?

dgroh commented 5 years ago

same here, any workaround? we have legacy services and we need to consume them in out .netcore application

james-novino commented 5 years ago

There was some guidance in another thread to reference System.ServiceModel.Primitives, however, this didn't fix this issue for us. So any guidance on this issue would be appreciated: https://github.com/dotnet/wcf/issues/2293

opejanovic commented 4 years ago

Same problem here. @hongdai why this thread is closed? IMHO this is important functionality.

opejanovic commented 4 years ago

@dgroh this looks like a workaround https://www.seeleycoder.com/blog/using-wcf-with-dotnetcore/ I did not test it, but looks promising

mstrate commented 2 years ago

Possibly this: https://docs.microsoft.com/en-us/dotnet/core/additional-tools/dotnet-svcutil-guide?tabs=dotnetsvcutil2x