19

I have got some classes generated by wsdl for soap web services. These are using namespace System.Web.Services. How can I use them in asp.net core?

eadam
  • 23,151
  • 18
  • 48
  • 71

1 Answers1

10

I have answered few days back on following question.

ASP.NET 5 add WCF service reference

In above case there is a WCF service and in your case it is Web Service.

Following thing you should concern or consider.

  1. It will not work with CoreCLR
  2. You have to add reference to "System.Web.Services" following way.

    aspnet50": { "frameworkAssemblies": {
    "System.Web.Services": "" }, "dependencies": { "ClassLibrary2": "1.0.0-*" } }

All other steps are similar that you have to create classlibrary project and add reference of that project or directly add class generated from WSDL to your asp.net 5 project.

Note : For this answer I have used VS 2015 CTP 5.

Community
  • 1
  • 1
dotnetstep
  • 17,065
  • 5
  • 54
  • 72
  • 1
    Probably a better solution for ASP.NET 5 and MVC 6 is to use answer http://stackoverflow.com/a/28440491/3912048 from that same question. That will allow you to talk to an ASMX web service without needing System.Web or building a separate assembly. The only downside is that you will need to generate new proxy classes using svcutil.exe since the ones created by wsdl.exe do have the System.Web dependency. svcutil.exe will work for ASMX and WCF services, though. See https://msdn.microsoft.com/en-us/library/vstudio/ms751529%28v=vs.100%29.aspx for more on using svcutil with ASMX services – Adam Feb 21 '15 at 00:29
  • If you look at this question then it has specific use of utility called WSDL. When class generate using WSDL then it has dependency on System.Web.Services. – dotnetstep Feb 21 '15 at 01:02
  • Yes, you're correct that if you MUST use the classes generated by wsdl.exe then you'll have the System.Web.Services dependency. If you only care about interacting with the ASMX service, though, using scvutil is a better option because you can use the new ASP.NET 5 stack (and MVC 6 as the question asked) instead of being limited to targeting net45. – Adam Feb 21 '15 at 01:08
  • 2
    Since it seems like dnx is changing a lot with each release, I just want to mention that in order for me to build and run a project with System.Web.Service, I had to add `dnx451": { "frameworkAssemblies": { "System.Web.Services": "" }, "dependencies": { "ClassLibrary2": "1.0.0-*" } }` and remove `dnxcore50": { }` altogether. This is as of beta7. Im my example, you' might also be noticing `dnx451` and `dnxcore` instead of `aspnet45` and `aspnet50` that appear in almost all the other posts about this topic on SO. Not sure the reason this was done, but its used all throughout github.com/aspnet. – smulholland2 Oct 19 '15 at 22:16
  • 1
    @Nulref yes it may change now. I did answer when it was CTP 5 – dotnetstep Oct 21 '15 at 04:02
  • 3
    There is now an extension for this http://blogs.msdn.com/b/webdev/archive/2015/12/15/wcf-connected-service-visual-studio-extension-preview-for-asp-net-5-projects.aspx – Jon49 Jan 07 '16 at 17:18