Long time ago, in a world far far away, we used to be able to add web service references to projects simply by right-clicking on the project's References node, and clicking "Add Service Reference". I used to be able to do this with .asmx services, and traditional WCF service.
When I follow different online instructions on "making my WCF RESTful", do I also lose the ability to "Add Service Reference" to those WCF services? Can WCF based REST services be added this way?
If I use Web API 2, can I "Add Service Reference"?
Assume I'm using the latest of everything - VS2015, etc.
When I follow different online instructions on "making my WCF RESTful", do I also lose the ability to "Add Service Reference" to those WCF services? Can WCF based REST services be added this way?
Kind of. You can add a REST MEX endpoint, but I don't think you can use that to generate a service proxy. Though, I think a better question might be, why would you want to? Web API is the best way to go for REST.
If I use Web API 2, can I "Add Service Reference"?
No. Web API doesn't have any type of metadata functionality like WCF.
Related
the question is simple..
we usually use web reference to consume the web services literally(visual studio). But, my problem is another way round. I need to call a particular web service from a c# class to make the web service available to be consumed by others.
First of all, if you have a choice, you should be using WCF on both the server and client. If you can't use it on the server for some reason, then at least use it on the client by using "Add Service Reference" instead of "Add Web Reference". "Add Web Reference" is part of the legacy ASMX technology, which should not be used for new development.
Secondly, of course you can create a separate class library, and use "Add Service Reference" in that library. You can then write a class that has public methods which call the service. The users of this class library will call your public methods, and will not directly call the service.
You can extract the C# code class of a Web Reference by unfolding the web reference in VS, (by showing hidden files if I remember well).
You should find a Reference.cs file which is the proxy client code for your web Service.
It contains everything you need to call your WS. You can copy it elsewhere, include it in another project, change its namespace/code etc. On the long run, maintainance of this file will be a pain if the corresponding WS evolves.
Anyway, if you have the choice, you should follow #JohnSaunders advice on WCF
I have 2 WCF services now and I want to construct the WCF Service which will use 2 WCF Services(trying to make coarse-grained service).But as you know for making wcf service; create wcf service library and I construct all methods ,write on WCF Service Library.And then I create New Web Site which is WCF Service and I link it to WCF Service Library.
But there exist a problem at that moment; I can't use WCF Service References in the WCF Service Libraries..NET FrameWork can't use wcf service methods in independent WCF Service Library.What is the solution ? The problem is a bit confusing but I think a lot of people are trying to solve this problem ...
You have to move/merge configuration of the referenced WCF services from app.config of your WCF Service Library, to the Web Site's web.config. Everything else should work out of the box.
But there exist a problem at that
moment; I can't use WCF Service
References in the WCF Service
Libraries..NET FrameWork can't use wcf
service methods in independent WCF
Service Library.
?? What do you mean by that?? That doesn't make sense at all. Can you please explain a bit more what you have and what doesn't work??
My "best practice" approach is to have at least two projects for a WCF service:
1) Contracts: all contracts (service, operation, data, fault) go here - only the contracts, nothing else.
2) Service implementation: the actual service code - the code that implements those contracts
Optionally, I might have a third project for hosting the service, not relevant in your case if you have hosting in IIS.
On the client side, I typically also use two projects:
1) ClientProxies which contains all the proxies / service references for others to use
2) Client(s) are the ultimate users of my service - an Winforms App, a WPF app, ASP.NET etc.
I use this approach a lot and I've never had any trouble with not being able to use a service reference or anything, as you say.....
I have 2 web services with about 6 web methods in total, most of the code is ofc sitting in assemblies any way, and the web service asmx is really just calling these assembly methods and returning their return type.
How much effort is it to convert the web services from ASMX to WCF?
I pretty much at this stage control the only - non web based clients connecting to the web services, so this is not really a problem, product is in prelaunch.
Check out some of those blog posts and articles on how to do it:
Migrating ASMX to WCF (unfortunately, this link in no longer valid)
Phased Migration From ASMX to WCF
ASMX to WCF migration
and many more - search for "Migration ASMX to WCF" and you'll get a ton of hits
Marc
You should find it extremely simple to convert - especially if your existing asmx web methods are just calling into other classes. Just create a new WCF Service from Visual Studio - that way you still have your existing web services intact. It will automatically create an http end-point for your so you can just dump it straight into IIS (with a little configuration). You will need to describe your DataContract classes but that it trivially simple too.
I did this recently and it was a joy!
i am new to c# language.i saw that you wrote the c# client application to the axis2 web service.i also want to know how i write C# client for the axis2 application
I believe that Axis exposes WSDL in the normal way, so you should be able to use "Add Web Reference" from Visual Studio, point it at the relevant Axis WSDL URL, and use the autogenerated client proxy.
I seem to remember there are some subtleties around using null vs empty arrays, but mostly it works fine - or did when I last tried several years ago, anyway.
For any new web service development, I suggest you use WCF instead of the old-style ASMX web services framework that you would get from using "Add Web Reference". Use "Add Service Reference" instead. ASMX is next to obsolete, in the sense that only critical security fixes are expected.
Many AXIS2 services are configured with WS-Security enabled, and WCF is the only practical way to handle those.
I have a question. How can i invoke a web service and get the result from a C# desktop application. I am making a desktop app and I want it to be able to connect to my online ASP.net web services. How is this possible?
In Solution Explorer, right-click your project node and select Add Service Reference.
Enter the URL where your service WSDL is located. This is usually the URL of the service itself.
This generates a strongly-typed proxy class in a new Services References folder in your project.
Write code in your desktop app to instantiate the proxy class and invoke methods on it. The rest works like magic. :)
AB Kolan was also correct, but Add Web Reference uses the old-style web services framework whereas Add Service References uses the new WCF stack. Important note: It is not required that the service itself use WCF for you to use WCF on the client side. WCF on the client is typically the best choice for any service, provided you can take a dependency on .NET 3.0 and above.
Add a Web Reference to the webservice in your Desktop App project reference. Doing so would generate a Proxy for the Webservice called Reference.cs
You can access your webservice using the proxy.
This is possible the same way that you access web services from any other type of application, be it an ASP.NET page, a class library or windows service.
For an explanatory tutorial on the subject, see Accessing a Web Service from a Desktop Application.
Will get help how to create a webservice and consume that service:
http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-web-service-in-Asp-Net-web-application/
Thanks